[svn-commits] branch crichter/0.4.0 r36083 - in /team/crichter/0.4.0: ./ apps/ channels/ ch...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Mon Jun 26 10:48:56 MST 2006


Author: crichter
Date: Mon Jun 26 12:48:55 2006
New Revision: 36083

URL: http://svn.digium.com/view/asterisk?rev=36083&view=rev
Log:
Merged revisions 34403,34551,34603,34633,34669,34761,34787,34878,34918,35061,35128,35240,35338,35672,35918,36045,36081 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/team/crichter/0.3.0

........
r34403 | root | 2006-06-16 06:00:40 +0200 (Fr, 16 Jun 2006) | 1 line

automerge commit
........
r34551 | crichter | 2006-06-17 12:32:20 +0200 (Sa, 17 Jun 2006) | 6 lines

* fixed bchannel cleaning race condition with new bchannel state (CLEAN_REQUEST)
* added early bridge-hook, so we know if we need to generate ringing or 
  can take it from the far end chan_misdn channel (if available)



........
r34603 | crichter | 2006-06-18 21:02:06 +0200 (So, 18 Jun 2006) | 1 line

added TONE_HANGUP, also added Tone generation by mISDN_dsp for post hangup tones, therefore the TONE_X defines are in the isdn_lib.h now. changed a REALEASE to a DISCONNECT in NT Stack, to make tones available in that state.
........
r34633 | root | 2006-06-18 23:00:29 +0200 (So, 18 Jun 2006) | 1 line

automerge commit
........
r34669 | root | 2006-06-19 00:00:24 +0200 (Mo, 19 Jun 2006) | 1 line

automerge commit
........
r34761 | crichter | 2006-06-19 09:34:51 +0200 (Mo, 19 Jun 2006) | 1 line

we need to send DISCONNECT on Timeout in the ALERTING/PROCEEDING cases too
........
r34787 | crichter | 2006-06-19 11:43:13 +0200 (Mo, 19 Jun 2006) | 1 line

when we get a disconnect, we should stop the tones on te side..
........
r34878 | root | 2006-06-19 21:00:25 +0200 (Mo, 19 Jun 2006) | 1 line

automerge commit
........
r34918 | root | 2006-06-19 23:00:30 +0200 (Mo, 19 Jun 2006) | 1 line

automerge commit
........
r35061 | root | 2006-06-20 13:00:31 +0200 (Di, 20 Jun 2006) | 1 line

automerge commit
........
r35128 | root | 2006-06-20 18:00:24 +0200 (Di, 20 Jun 2006) | 1 line

automerge commit
........
r35240 | crichter | 2006-06-21 17:19:03 +0200 (Mi, 21 Jun 2006) | 20 lines

* added support for PID export/import to identify bridging in misdn_call already
* fixed a few inband Alerting issues, sometimes we need to create alerting, sometimes it's inband
* beautified the state debugging of misdn_hangup
* removed "real"  bchannel activating/deactivating in chan_misdn.c
* fixed "round_robin" bug when there's only 1 port
* added more informative prints when channel could not be created
* changed some warnings to notices
* reworked the whole bchannel state machine stuff, 
  it is now like in the examples of mISDNuser and therefore a lot easier, 
  and it is now harder to create bugs
* bchannel_activate/deactivate is now only called in setup/cleanup bc, 
  they may merge sometime
* it is very important to setup/cleanup the bchannels under the correct 
  conditions, especially in the NT Side we can only setup the bchannels 
  when we send a Message! 
  In the TE side we can only setup the bchannel when we received the channel 
  of course



........
r35338 | root | 2006-06-21 22:00:24 +0200 (Mi, 21 Jun 2006) | 1 line

automerge commit
........
r35672 | root | 2006-06-23 14:00:33 +0200 (Fr, 23 Jun 2006) | 1 line

automerge commit
........
r35918 | root | 2006-06-25 18:00:27 +0200 (So, 25 Jun 2006) | 1 line

automerge commit
........
r36045 | root | 2006-06-26 18:00:28 +0200 (Mo, 26 Jun 2006) | 1 line

automerge commit
........
r36081 | crichter | 2006-06-26 19:33:51 +0200 (Mo, 26 Jun 2006) | 9 lines

* fixed the busy state
* fixed tone handling after ast_hangup was called
* optimized the tone_indication function
* removed warnings in favour of log debugs
* improved the round_robin method
* added logs for channel setting/emptying
* fixed channel forgot to set bug


........

Modified:
    team/crichter/0.4.0/   (props changed)
    team/crichter/0.4.0/Makefile
    team/crichter/0.4.0/apps/app_queue.c
    team/crichter/0.4.0/apps/app_voicemail.c
    team/crichter/0.4.0/channels/chan_iax2.c
    team/crichter/0.4.0/channels/chan_misdn.c
    team/crichter/0.4.0/channels/chan_sip.c
    team/crichter/0.4.0/channels/misdn/ie.c
    team/crichter/0.4.0/channels/misdn/isdn_lib.c
    team/crichter/0.4.0/channels/misdn/isdn_lib.h
    team/crichter/0.4.0/configs/iax.conf.sample
    team/crichter/0.4.0/configs/indications.conf.sample
    team/crichter/0.4.0/pbx.c

Propchange: team/crichter/0.4.0/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Jun 26 12:48:55 2006
@@ -1,1 +1,1 @@
-/team/crichter/0.3.0:1-34340
+/team/crichter/0.3.0:1-36082

Modified: team/crichter/0.4.0/Makefile
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/Makefile?rev=36083&r1=36082&r2=36083&view=diff
==============================================================================
--- team/crichter/0.4.0/Makefile (original)
+++ team/crichter/0.4.0/Makefile Mon Jun 26 12:48:55 2006
@@ -906,13 +906,14 @@
 chan_misdn.so:
 	make -C . SUBDIRS=channels CHANNEL_LIBS=chan_misdn.so
 
-cm-install: chan_misdn.so
+cm-install: cm-clean chan_misdn.so
 	install -m 644 channels/chan_misdn.so /usr/lib/asterisk/modules/
 
 cm-clean:
+	make -C channels/misdn clean
+	
+cm-cleaner: cm-clean
 	rm -f channels/chan_misdn_config.o
 	rm -f channels/chan_misdn.o
 	rm -f channels/chan_misdn.so
 
-cm-cleaner:	cm-clean
-	make -C channels/misdn clean

Modified: team/crichter/0.4.0/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/apps/app_queue.c?rev=36083&r1=36082&r2=36083&view=diff
==============================================================================
--- team/crichter/0.4.0/apps/app_queue.c (original)
+++ team/crichter/0.4.0/apps/app_queue.c Mon Jun 26 12:48:55 2006
@@ -3425,9 +3425,11 @@
 			} else
 				ast_log(LOG_WARNING, "XXX Leaking a little memory :( XXX\n");
 		} else {
+			ast_mutex_lock(&q->lock);
 			for (cur = q->members; cur; cur = cur->next)
 				cur->status = ast_device_state(cur->interface);
 			ql = q;
+			ast_mutex_unlock(&q->lock);
 		}
 		q = qn;
 	}

Modified: team/crichter/0.4.0/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/apps/app_voicemail.c?rev=36083&r1=36082&r2=36083&view=diff
==============================================================================
--- team/crichter/0.4.0/apps/app_voicemail.c (original)
+++ team/crichter/0.4.0/apps/app_voicemail.c Mon Jun 26 12:48:55 2006
@@ -763,8 +763,10 @@
 {
 	char buf[255];
 	snprintf(buf,255,"%s %s %s %s",ext_pass_cmd,vmu->context,vmu->mailbox,newpassword);
-	if (!ast_safe_system(buf))
+	if (!ast_safe_system(buf)) {
+		reset_user_pw(vmu->context, vmu->mailbox, newpassword);
 		ast_copy_string(vmu->password, newpassword, sizeof(vmu->password));
+	}
 }
 
 static int make_dir(char *dest, int len, char *context, char *ext, char *mailbox)
@@ -2601,6 +2603,7 @@
 			if (duration < vmminmessage) {
 				if (option_verbose > 2) 
 					ast_verbose( VERBOSE_PREFIX_3 "Recording was %d seconds long but needs to be at least %d - abandoning\n", duration, vmminmessage);
+				fclose(txt);
 				ast_filedelete(tmptxtfile, NULL);
 				unlink(tmptxtfile);
 			} else {
@@ -2611,6 +2614,10 @@
 					/* Delete files */
 					ast_filedelete(tmptxtfile, NULL);
 					unlink(tmptxtfile);
+				} else if (ast_fileexists(tmptxtfile, NULL, NULL) <= 0) {
+					if (option_debug) 
+						ast_log(LOG_DEBUG, "The recorded media file is gone, so we should remove the .txt file too!\n");
+					unlink(tmptxtfile);	
 				} else {
 					for (;;) {
 						make_file(fn, sizeof(fn), dir, msgnum);
@@ -2644,7 +2651,7 @@
 							free_user(recip);
 						}
 					}
-					if (ast_fileexists(fn, NULL, NULL)) {
+					if (ast_fileexists(fn, NULL, NULL) > 0) {
 						STORE(dir, vmu->mailbox, vmu->context, msgnum);
 						notify_new_message(chan, vmu, msgnum, duration, fmt, chan->cid.cid_num, chan->cid.cid_name);
 						DISPOSE(dir, msgnum);

Modified: team/crichter/0.4.0/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_iax2.c?rev=36083&r1=36082&r2=36083&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_iax2.c (original)
+++ team/crichter/0.4.0/channels/chan_iax2.c Mon Jun 26 12:48:55 2006
@@ -8191,11 +8191,7 @@
 		peer->peercontext[0] = '\0';
 		while(v) {
 			if (!strcasecmp(v->name, "secret")) {
-				if (!ast_strlen_zero(peer->secret)) {
-					strncpy(peer->secret + strlen(peer->secret), ";", sizeof(peer->secret)-strlen(peer->secret) - 1);
-					strncpy(peer->secret + strlen(peer->secret), v->value, sizeof(peer->secret)-strlen(peer->secret) - 1);
-				} else
-					ast_copy_string(peer->secret, v->value, sizeof(peer->secret));
+				ast_copy_string(peer->secret, v->value, sizeof(peer->secret));
 			} else if (!strcasecmp(v->name, "mailbox")) {
 				ast_copy_string(peer->mailbox, v->value, sizeof(peer->mailbox));
 			} else if (!strcasecmp(v->name, "dbsecret")) {
@@ -9335,6 +9331,7 @@
 	struct iax2_peer *p;
 	int res = AST_DEVICE_INVALID;
 
+	memset(&pds, 0, sizeof(pds));
 	parse_dial_string(tmp, &pds);
 	if (!pds.peer || ast_strlen_zero(pds.peer))
 		return res;

Modified: team/crichter/0.4.0/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_misdn.c?rev=36083&r1=36082&r2=36083&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_misdn.c (original)
+++ team/crichter/0.4.0/channels/chan_misdn.c Mon Jun 26 12:48:55 2006
@@ -83,8 +83,6 @@
 	ast_mutex_t mutexjb;
 };
 
-void export_ies(struct ast_channel *chan, struct misdn_bchannel *bc);
-void import_ies(struct ast_channel *chan, struct misdn_bchannel *bc);
 
 
 /* allocates the jb-structure and initialise the elements*/
@@ -107,16 +105,6 @@
 
 /* BEGIN: chan_misdn.h */
 
-
-enum tone_e {
-	TONE_NONE=0,
-	TONE_DIAL,
-	TONE_ALERTING,
-	TONE_FAR_ALERTING,
-	TONE_BUSY,
-	TONE_CUSTOM,
-	TONE_FILE
-};
 
 
 enum misdn_chan_state {
@@ -133,6 +121,7 @@
 	MISDN_CONNECTED, /*!<  when connected */
 	MISDN_PRECONNECTED, /*!<  when connected */
 	MISDN_DISCONNECTED, /*!<  when connected */
+	MISDN_RELEASED, /*!<  when connected */
 	MISDN_BRIDGED, /*!<  when bridged */
 	MISDN_CLEANING, /*!< when hangup from * but we were connected before */
 	MISDN_HUNGUP_FROM_MISDN, /*!< when DISCONNECT/RELEASE/REL_COMP  cam from misdn */
@@ -180,6 +169,8 @@
 	struct ast_trans_pvt *trans;
   
 	struct ast_channel * ast;
+
+	int dummy;
   
 	struct misdn_bchannel *bc;
 	struct misdn_bchannel *holded_bc;
@@ -193,6 +184,8 @@
 	int dropped_frame_cnt;
 
 	int far_alerting;
+	int other_pid;
+	struct chan_list *other_ch;
 
 	const struct tone_zone_sound *ts;
 	
@@ -201,6 +194,11 @@
 	struct chan_list *prev;
 	struct chan_list *first;
 };
+
+
+
+void export_ch(struct ast_channel *chan, struct misdn_bchannel *bc, struct chan_list *ch);
+void import_ch(struct ast_channel *chan, struct misdn_bchannel *bc, struct chan_list *ch);
 
 struct robin_list {
 	char *group;
@@ -300,11 +298,12 @@
 static enum event_response_e
 cb_events(enum event_e event, struct misdn_bchannel *bc, void *user_data);
 
-static void send_cause2ast(struct ast_channel *ast, struct misdn_bchannel*bc);
+static void send_cause2ast(struct ast_channel *ast, struct misdn_bchannel*bc, struct chan_list *ch);
 
 static void cl_queue_chan(struct chan_list **list, struct chan_list *chan);
 static void cl_dequeue_chan(struct chan_list **list, struct chan_list *chan);
 static struct chan_list *find_chan_by_bc(struct chan_list *list, struct misdn_bchannel *bc);
+static struct chan_list *find_chan_by_pid(struct chan_list *list, int pid);
 
 
 
@@ -638,10 +637,14 @@
 	{MISDN_EXTCANTMATCH,"EXTCANTMATCH"}, /*  when asterisk couldnt match our ext */
 	{MISDN_DIALING,"DIALING"}, /*  when pbx_start */
 	{MISDN_PROGRESS,"PROGRESS"}, /*  when pbx_start */
+	{MISDN_PROCEEDING,"PROCEEDING"}, /*  when pbx_start */
 	{MISDN_CALLING,"CALLING"}, /*  when misdn_call is called */
+	{MISDN_CALLING_ACKNOWLEDGE,"CALLING_ACKNOWLEDGE"}, /*  when misdn_call is called */
 	{MISDN_ALERTING,"ALERTING"}, /*  when Alerting */
 	{MISDN_BUSY,"BUSY"}, /*  when BUSY */
 	{MISDN_CONNECTED,"CONNECTED"}, /*  when connected */
+	{MISDN_DISCONNECTED,"DISCONNECTED"}, /*  when connected */
+	{MISDN_RELEASED,"RELEASED"}, /*  when connected */
 	{MISDN_BRIDGED,"BRIDGED"}, /*  when bridged */
 	{MISDN_CLEANING,"CLEANING"}, /* when hangup from * but we were connected before */
 	{MISDN_HUNGUP_FROM_MISDN,"HUNGUP_FROM_MISDN"}, /* when DISCONNECT/RELEASE/REL_COMP  cam from misdn */
@@ -654,13 +657,17 @@
 static char *misdn_get_ch_state(struct chan_list *p) 
 {
 	int i;
+	static char state[8];
+	
 	if( !p) return NULL;
   
 	for (i=0; i< sizeof(state_array)/sizeof(struct state_struct); i++) {
 		if ( state_array[i].state == p->state) return state_array[i].txt; 
 	}
-  
-	return NULL;
+
+ 	sprintf(state,"%d",p->state) ;
+
+	return state;
 }
 
 
@@ -1637,7 +1644,7 @@
 		update_config(ch,ORG_AST);
 		
 		/* fill in some ies from channel vary*/
-		import_ies(ast, newbc);
+		import_ch(ast, newbc, ch);
 		
 		/* Finally The Options Override Everything */
 		if (opts)
@@ -1827,7 +1834,7 @@
 		chan_misdn_log(1, p->bc->port, "* IND :\tbusy\n");
 		chan_misdn_log(1, p->bc->port, " --> * SEND: State Busy pid:%d\n",p->bc?p->bc->pid:-1);
 		ast_setstate(ast,AST_STATE_BUSY);
-		
+
 		p->bc->out_cause=17;
 		if (p->state != MISDN_CONNECTED) {
 			misdn_lib_send_event( p->bc, EVENT_DISCONNECT);
@@ -1853,10 +1860,30 @@
 				p->state=MISDN_ALERTING;
 				chan_misdn_log(1, p->bc->port, " --> * IND :\tringing pid:%d\n",p->bc?p->bc->pid:-1);
 				misdn_lib_send_event( p->bc, EVENT_ALERTING);
-				
+			
+				if (p->other_ch && p->other_ch->bc) {
+					if (misdn_inband_avail(p->other_ch->bc)) {
+						chan_misdn_log(1,p->bc->port, " --> other End is mISDN and has inband info available\n");
+						break;
+					}
+
+					if (!p->other_ch->bc->nt) {
+						chan_misdn_log(1,p->bc->port, " --> other End is mISDN TE so it has inband info for sure (?)\n");
+						break;
+					}
+#if 0
+					if (p->other_ch->bc->nt) {
+						chan_misdn_log(1,p->bc->port, " --> other End is mISDN NT .. \n");
+						break;
+					}
+#endif
+
+				}
+
+			
 				if ( !p->bc->nt && (p->orginator==ORG_MISDN) && !p->incoming_early_audio ) 
 					chan_misdn_log(1,p->bc->port, " --> incoming_early_audio off\n");
-				 else 
+				else 
 					 tone_indicate(p, TONE_ALERTING);
 				chan_misdn_log(1, p->bc->port, " --> * SEND: State Ring pid:%d\n",p->bc?p->bc->pid:-1);
 				ast_setstate(ast,AST_STATE_RINGING);
@@ -1901,10 +1928,11 @@
 	case -1 :
 		chan_misdn_log(1, p->bc->port, " --> * IND :\t-1! (stop indication) pid:%d\n",p->bc?p->bc->pid:-1);
 		
-		if (p->state == MISDN_CONNECTED)
+		tone_indicate(p, TONE_NONE);
+
+		if (p->state == MISDN_CONNECTED) 
 			start_bc_tones(p);
-		else 
-			tone_indicate(p, TONE_NONE);
+
 		break;
 
 	case AST_CONTROL_HOLD:
@@ -1914,7 +1942,7 @@
 		chan_misdn_log(1, p->bc->port, " --> *\tUNHOLD pid:%d\n",p->bc?p->bc->pid:-1);
 		break;
 	default:
-		ast_log(LOG_WARNING, " --> * Unknown Indication:%d pid:%d\n",cond,p->bc?p->bc->pid:-1);
+		ast_log(LOG_NOTICE, " --> * Unknown Indication:%d pid:%d\n",cond,p->bc?p->bc->pid:-1);
 	}
   
 	return 0;
@@ -1966,13 +1994,15 @@
 		return 0;
 	}
 
-	stop_bc_tones(p);
+	if (!p->bc->nt) 
+		stop_bc_tones(p);
+
 	
 	release_unlock;
 	
 	{
 		const char *varcause=NULL;
-		bc->cause=ast->hangupcause?ast->hangupcause:16;
+		bc->out_cause=ast->hangupcause?ast->hangupcause:16;
 		
 		if ( (varcause=pbx_builtin_getvar_helper(ast, "HANGUPCAUSE")) ||
 		     (varcause=pbx_builtin_getvar_helper(ast, "PRI_CAUSE"))) {
@@ -1984,6 +2014,7 @@
 		chan_misdn_log(2, bc->port, " --> l3id:%x\n",p->l3id);
 		chan_misdn_log(1, bc->port, " --> cause:%d\n",bc->cause);
 		chan_misdn_log(1, bc->port, " --> out_cause:%d\n",bc->out_cause);
+		chan_misdn_log(1, bc->port, " --> state:%s\n", misdn_get_ch_state(p));
 		
 		switch (p->state) {
 		case MISDN_CALLING:
@@ -1992,67 +2023,74 @@
 			break;
 		case MISDN_HOLDED:
 		case MISDN_DIALING:
+		case MISDN_CALLING_ACKNOWLEDGE:
 			start_bc_tones(p);
-			tone_indicate(p, TONE_BUSY);
-			p->state=MISDN_CLEANING;
-			
-			misdn_lib_send_event( bc, EVENT_RELEASE_COMPLETE);
-      
+			tone_indicate(p, TONE_HANGUP);
+		
+			if (bc->nt) {
+				misdn_lib_send_event( bc, EVENT_DISCONNECT);
+			} else {
+				misdn_lib_send_event( bc, EVENT_RELEASE_COMPLETE);
+				p->state=MISDN_CLEANING;
+			}
 			break;
       
 		case MISDN_ALERTING:
 		case MISDN_PROGRESS:
 		case MISDN_PROCEEDING:
-			chan_misdn_log(2, bc->port, " --> * State Alerting\n");
-
 			if (p->orginator != ORG_AST) 
-				tone_indicate(p, TONE_BUSY);
+				tone_indicate(p, TONE_HANGUP);
       
-			p->state=MISDN_CLEANING;
+			/*p->state=MISDN_CLEANING;*/
 			misdn_lib_send_event( bc, EVENT_DISCONNECT);
 			break;
 		case MISDN_CONNECTED:
 			/*  Alerting or Disconect */
-			chan_misdn_log(2, bc->port, " --> * State Connected\n");
-			start_bc_tones(p);
-			tone_indicate(p, TONE_BUSY);
+			if (p->bc->nt) {
+				start_bc_tones(p);
+				tone_indicate(p, TONE_HANGUP);
+				p->bc->progress_indicator=8;
+			}
 			misdn_lib_send_event( bc, EVENT_DISCONNECT);
-      
-			p->state=MISDN_CLEANING; /* MISDN_HUNGUP_FROM_AST; */
+
+			/*p->state=MISDN_CLEANING;*/
 			break;
 		case MISDN_DISCONNECTED:
-			chan_misdn_log(2, bc->port, " --> * State Disconnected\n");
 			misdn_lib_send_event( bc, EVENT_RELEASE);
 			p->state=MISDN_CLEANING; /* MISDN_HUNGUP_FROM_AST; */
 			break;
 
+		case MISDN_RELEASED:
 		case MISDN_CLEANING:
+			p->state=MISDN_CLEANING;
+			break;
+
+		case MISDN_BUSY:
 			break;
       
 		case MISDN_HOLD_DISCONNECT:
 			/* need to send release here */
-			chan_misdn_log(2, bc->port, " --> state HOLD_DISC\n");
 			chan_misdn_log(1, bc->port, " --> cause %d\n",bc->cause);
 			chan_misdn_log(1, bc->port, " --> out_cause %d\n",bc->out_cause);
 			
 			bc->out_cause=-1;
 			misdn_lib_send_event(bc,EVENT_RELEASE);
+			p->state=MISDN_CLEANING;
 			break;
 		default:
-			/*  Alerting or Disconect */
-
 			if (bc->nt) {
 				bc->out_cause=-1;
 				misdn_lib_send_event(bc, EVENT_RELEASE);
-			} else
+				p->state=MISDN_CLEANING; 
+			} else {
 				misdn_lib_send_event(bc, EVENT_DISCONNECT);
-			p->state=MISDN_CLEANING; /* MISDN_HUNGUP_FROM_AST; */
+			}
 		}
     
 	}
 	
 
-	chan_misdn_log(1, bc->port, "Channel: %s hanguped\n",ast->name);
+	chan_misdn_log(1, bc->port, "Channel: %s hanguped new state:%s\n",ast->name,misdn_get_ch_state(p));
 	
 	return 0;
 }
@@ -2065,7 +2103,7 @@
 	if (!ast) return NULL;
 	if (! (tmp=MISDN_ASTERISK_TECH_PVT(ast)) ) return NULL;
 	if (!tmp->bc) return NULL;
-	
+
 	len=read(tmp->pipe[0],tmp->ast_rd_buf,sizeof(tmp->ast_rd_buf));
 	
 	if (len<=0) {
@@ -2073,7 +2111,7 @@
 		chan_misdn_log(2,tmp->bc->port,"misdn_read: Pipe closed, hanging up\n");
 		return NULL;
 	}
-	
+
 	tmp->frame.frametype  = AST_FRAME_VOICE;
 	tmp->frame.subclass = AST_FORMAT_ALAW;
 	tmp->frame.datalen = len;
@@ -2301,6 +2339,10 @@
 	chan_misdn_log(3,cl->bc->port,"Tone Indicate:\n");
 	
 	if (!cl->ast) {
+		chan_misdn_log(3,cl->bc->port,"Ast Ptr Not existing anymore.. we need to generate tones ourselves now (tbd)\n");
+		
+		misdn_lib_send_tone(cl->bc,tone);
+		misdn_lib_tone_generator_start(cl->bc);
 		return 0;
 	}
 	
@@ -2308,24 +2350,20 @@
 	case TONE_DIAL:
 		chan_misdn_log(3,cl->bc->port," --> Dial\n");
 		ts=ast_get_indication_tone(ast->zone,"dial");
-		misdn_lib_tone_generator_start(cl->bc);
 		break;
 	case TONE_ALERTING:
 		chan_misdn_log(3,cl->bc->port," --> Ring\n");
 		ts=ast_get_indication_tone(ast->zone,"ring");
-		misdn_lib_tone_generator_stop(cl->bc);
 		break;
 	case TONE_FAR_ALERTING:
 	/* VERY UGLY HACK, BECAUSE CHAN_SIP DOES NOT GENERATE TONES */
 		chan_misdn_log(3,cl->bc->port," --> Ring\n");
 		ts=ast_get_indication_tone(ast->zone,"ring");
-		misdn_lib_tone_generator_start(cl->bc);
 		misdn_lib_echo(cl->bc,1);
 		break;
 	case TONE_BUSY:
 		chan_misdn_log(3,cl->bc->port," --> Busy\n");
 		ts=ast_get_indication_tone(ast->zone,"busy");
-		misdn_lib_tone_generator_stop(cl->bc);
 		break;
 	case TONE_FILE:
 		break;
@@ -2340,14 +2378,20 @@
 	
 	cl->ts=ts;	
 	
-	if (ts) ast_playtones_start(ast,0, ts->data, 0);
+	if (ts) {
+		cl->notxtone=0;
+		cl->norxtone=0;
+		ast_playtones_start(ast,0, ts->data, 0);
+		chan_misdn_log(4,cl->bc->port,"Starting Playtones\n");
+		misdn_lib_tone_generator_start(cl->bc);
+	}
 	
 	return 0;
 }
 
 static int start_bc_tones(struct chan_list* cl)
 {
-	manager_bchannel_activate(cl->bc);
+/*	manager_bchannel_activate(cl->bc); */
 	misdn_lib_tone_generator_stop(cl->bc);
 	cl->notxtone=0;
 	cl->norxtone=0;
@@ -2356,9 +2400,10 @@
 
 static int stop_bc_tones(struct chan_list *cl)
 {
-	if (cl->bc) {
+/*	if (cl->bc) {
 		manager_bchannel_deactivate(cl->bc);
 	}
+*/
 	cl->notxtone=1;
 	cl->norxtone=1;
 	
@@ -2412,7 +2457,7 @@
 			chan_misdn_log(2, 0, " --> Group Call group: %s\n",group);
 		} 
 		else if ((p = strchr(port_str, ':'))) {
-			// we have a preselected channel
+			/* we have a preselected channel */
 			*p = 0;
 			channel = atoi(++p);
 			port = atoi(port_str);
@@ -2454,8 +2499,9 @@
 					if (port >= port_start)
 						next_chan = 1;
 					
-					if (port < port_start && next_chan) {
-						if (++robin_channel >= MAX_BCHANS) {
+					if (port <= port_start && next_chan) {
+						int maxbchans=misdn_lib_get_maxchans(port);
+						if (++robin_channel >= maxbchans) {
 							robin_channel = 1;
 						}
 						next_chan = 0;
@@ -2468,13 +2514,17 @@
 						int check;
 						misdn_cfg_get(port, MISDN_CFG_PMP_L1_CHECK, &check, sizeof(int));
 						port_up = misdn_lib_port_up(port, check);
+
+						if (check && !port_up) 
+							chan_misdn_log(1,port,"L1 is not Up on this Port\n");
+						
 						
 						if ( port_up )	{
 							newbc = misdn_lib_get_free_bc(port, robin_channel);
 							if (newbc) {
 								chan_misdn_log(4, port, " Success! Found port:%d channel:%d\n", newbc->port, newbc->channel);
 								if (port_up)
-									chan_misdn_log(4, port, "ortup:%d\n",  port_up);
+									chan_misdn_log(4, port, "portup:%d\n",  port_up);
 								rr->port = newbc->port;
 								rr->channel = newbc->channel;
 								break;
@@ -2519,8 +2569,7 @@
 	}
 	
 	if (!newbc) {
-		chan_misdn_log(-1, 0, " --> ! No free channel chan ext:%s even after Group Call\n",ext);
-		chan_misdn_log(-1, 0, " --> SEND: State Down\n");
+		chan_misdn_log(-1, 0, "Could not create channel on port:%d with extensions:%s\n",port,ext);
 		return NULL;
 	}
 
@@ -2748,6 +2797,17 @@
 	return NULL;
 }
 
+static struct chan_list *find_chan_by_pid(struct chan_list *list, int pid)
+{
+	struct chan_list *help=list;
+	for (;help; help=help->next) {
+		if (help->bc->pid == pid) return help;
+	}
+  
+	chan_misdn_log(6, 0, "$$$ find_chan: No channel found for pid:%d\n",pid);
+  
+	return NULL;
+}
 
 static struct chan_list *find_holded(struct chan_list *list, struct misdn_bchannel *bc)
 {
@@ -2839,8 +2899,15 @@
 		release_unlock;
 		
 		chan_misdn_log(1, bc->port, "release_chan: bc with l3id: %x\n",bc->l3_id);
-		
-		//releaseing jitterbuffer
+#if 0
+		if (ch->dummy) {
+			ast_hangup(ast);
+			ch->ast=NULL;
+			ast=NULL;
+		}
+#endif
+		
+		/*releaseing jitterbuffer*/
 		if (ch->jb ) {
 			misdn_jb_destroy(ch->jb);
 			ch->jb=NULL;
@@ -2865,7 +2932,7 @@
 				chan_misdn_log(1, bc->port, "* RELEASING CHANNEL pid:%d ctx:%s dad:%s oad:%s state: %s\n",bc?bc->pid:-1, ast->context, ast->exten,AST_CID_P(ast),misdn_get_ch_state(ch));
 				chan_misdn_log(3, bc->port, " --> * State Down\n");
 				/* copy cause */
-				send_cause2ast(ast,bc);
+				send_cause2ast(ast,bc,ch);
 				
 				MISDN_ASTERISK_TECH_PVT(ast)=NULL;
 				
@@ -2887,11 +2954,13 @@
 				case MISDN_DIALING:
 				case MISDN_CALLING_ACKNOWLEDGE:
 				case MISDN_PROGRESS:
+				case MISDN_PROCEEDING:
 					chan_misdn_log(2,  bc->port, "* --> In State Dialin\n");
 					chan_misdn_log(2,  bc->port, "* --> Queue Hangup\n");
 					
-
+					ch->state=MISDN_CLEANING;
 					ast_queue_hangup(ast);
+					
 					break;
 				case MISDN_CALLING:
 					
@@ -3010,7 +3079,7 @@
 
 
 
-static void send_cause2ast(struct ast_channel *ast, struct misdn_bchannel*bc) {
+static void send_cause2ast(struct ast_channel *ast, struct misdn_bchannel*bc, struct chan_list *ch) {
 	
 	ast->hangupcause=bc->cause;
 	
@@ -3027,6 +3096,7 @@
 		 * the inband message
 		 *
 		chan_misdn_log(1, bc?bc->port:0, " --> * SEND: Queue Congestion pid:%d\n", bc?bc->pid:-1);
+		ch->state=MISDN_BUSY;
 		
 		ast_queue_control(ast, AST_CONTROL_CONGESTION);
 		*/
@@ -3035,50 +3105,36 @@
 	case 21:
 	case 17: /* user busy */
 		chan_misdn_log(1,  bc?bc->port:0, " --> * SEND: Queue Busy pid:%d\n", bc?bc->pid:-1);
-		
+	
+		ch->state=MISDN_BUSY;
 		ast_queue_control(ast, AST_CONTROL_BUSY);
 		
 		break;
 	}
 }
 
-void import_ies(struct ast_channel *chan, struct misdn_bchannel *bc)
+void import_ch(struct ast_channel *chan, struct misdn_bchannel *bc, struct chan_list *ch)
 {
 	char *tmp;
-	
-	tmp=pbx_builtin_getvar_helper(chan,"PRI_MODE");
-	if (tmp) bc->mode=atoi(tmp);
-	tmp=pbx_builtin_getvar_helper(chan,"PRI_URATE");
-	if (tmp) bc->urate=atoi(tmp);
-	
-	tmp=pbx_builtin_getvar_helper(chan,"PRI_RATE");
-	if (tmp) bc->rate=atoi(tmp);
-	
-	tmp=pbx_builtin_getvar_helper(chan,"PRI_USER1");
-	if (tmp) bc->user1=atoi(tmp);
-
-	tmp=pbx_builtin_getvar_helper(chan,"PRI_PROGRESS_INDICATOR");
-	if (tmp) bc->progress_indicator=atoi(tmp);
+	tmp=pbx_builtin_getvar_helper(chan,"MISDN_PID");
+	if (tmp) {
+		ch->other_pid=atoi(tmp);
+		chan_misdn_log(1,bc->port,"IMPORT_PID: importing pid:%s\n",tmp);
+
+		if (ch->other_pid >0) {
+			ch->other_ch=find_chan_by_pid(cl_te,ch->other_pid);
+			if (ch->other_ch) ch->other_ch->other_ch=ch;
+		}
+	}
 }
  
-void export_ies(struct ast_channel *chan, struct misdn_bchannel *bc)
+void export_ch(struct ast_channel *chan, struct misdn_bchannel *bc, struct chan_list *ch)
 {
 	char tmp[32];
-	
-	sprintf(tmp,"%d",bc->mode);
-	pbx_builtin_setvar_helper(chan,"_PRI_MODE",tmp);
-	
-	sprintf(tmp,"%d",bc->urate);
-	pbx_builtin_setvar_helper(chan,"_PRI_URATE",tmp);
-	
-	sprintf(tmp,"%d",bc->rate);
-	pbx_builtin_setvar_helper(chan,"_PRI_RATE",tmp);
-	
-	sprintf(tmp,"%d",bc->user1);
-	pbx_builtin_setvar_helper(chan,"_PRI_USER1",tmp);
-
-	sprintf(tmp,"%d",bc->progress_indicator);
-	pbx_builtin_setvar_helper(chan,"_PRI_PROGRESS_INDICATOR",tmp);
+
+	chan_misdn_log(1,bc->port,"EXPORT_PID: pid:%d\n",bc->pid);
+	sprintf(tmp,"%d",bc->pid);
+	pbx_builtin_setvar_helper(chan,"_MISDN_PID",tmp);
 }
 
 
@@ -3129,7 +3185,7 @@
 		ch=find_chan_by_l3id(cl_te, bc->l3_id);
 	
 	if (event != EVENT_BCHAN_DATA && event != EVENT_TONE_GENERATE) { /*  Debug Only Non-Bchan */
-		chan_misdn_log(1, bc->port, "I IND :%s oad:%s dad:%s\n", manager_isdn_get_info(event), bc->oad, bc->dad);
+		chan_misdn_log(1, bc->port, "I IND :%s oad:%s dad:%s pid:%d\n", manager_isdn_get_info(event), bc->oad, bc->dad, bc->pid);
 		misdn_lib_log_ies(bc);
 		chan_misdn_log(2,bc->port," --> bc_state:%s\n",bc_state2str(bc->bc_state));
 	}
@@ -3137,21 +3193,27 @@
 	if (event != EVENT_SETUP) {
 		if (!ch) {
 			if (event != EVENT_CLEANUP )
-				ast_log(LOG_WARNING, "Chan not existing at the moment bc->l3id:%x bc:%p event:%s port:%d channel:%d\n",bc->l3_id, bc, manager_isdn_get_info( event), bc->port,bc->channel);
+				ast_log(LOG_NOTICE, "Chan not existing at the moment bc->l3id:%x bc:%p event:%s port:%d channel:%d\n",bc->l3_id, bc, manager_isdn_get_info( event), bc->port,bc->channel);
 			return -1;
 		}
 	}
 	
 	if (ch ) {
 		switch (event) {
+		case EVENT_TONE_GENERATE:
+		break;
+		case EVENT_DISCONNECT:
 		case EVENT_RELEASE:
 		case EVENT_RELEASE_COMPLETE:
 		case EVENT_CLEANUP:
+		case EVENT_TIMEOUT:
+			if (!ch->ast)
+				chan_misdn_log(3,bc->port,"ast_hangup already called, so we have no ast ptr anymore in event(%s)\n",manager_isdn_get_info(event));
 			break;
 		default:
 			if ( !ch->ast  || !MISDN_ASTERISK_PVT(ch->ast) || !MISDN_ASTERISK_TECH_PVT(ch->ast)) {
 				if (event!=EVENT_BCHAN_DATA)
-					ast_log(LOG_WARNING, "No Ast or No private Pointer in Event (%d:%s)\n", event, manager_isdn_get_info(event));
+					ast_log(LOG_NOTICE, "No Ast or No private Pointer in Event (%d:%s)\n", event, manager_isdn_get_info(event));
 				return -1;
 			}
 		}
@@ -3259,10 +3321,8 @@
 				ch->state=MISDN_EXTCANTMATCH;
 				bc->out_cause=1;
 
-				if (bc->nt)
-					misdn_lib_send_event(bc, EVENT_RELEASE_COMPLETE );
-				else
-					misdn_lib_send_event(bc, EVENT_DISCONNECT );
+				misdn_lib_send_event(bc, EVENT_DISCONNECT );
+
 				break;
 			}
 			if (ast_exists_extension(ch->ast, ch->context, bc->dad, 1, bc->oad)) {
@@ -3275,10 +3335,7 @@
 					chan_misdn_log(-1, bc->port, "ast_pbx_start returned < 0 in INFO\n");
 					tone_indicate(ch,TONE_BUSY);
 
-					if (bc->nt)
-						misdn_lib_send_event(bc, EVENT_RELEASE_COMPLETE );
-					else
-						misdn_lib_send_event(bc, EVENT_DISCONNECT );
+					misdn_lib_send_event(bc, EVENT_DISCONNECT );
 				}
 			}
 	
@@ -3356,8 +3413,8 @@
 
 		read_config(ch, ORG_MISDN);
 		
-		export_ies(chan, bc);
-		
+		export_ch(chan, bc, ch);
+
 		ch->ast->rings=1;
 		ast_setstate(ch->ast, AST_STATE_RINGING);
 
@@ -3482,10 +3539,18 @@
 			}
 		} else {
 
-
 			if (bc->sending_complete) {
+				ch->state=MISDN_EXTCANTMATCH;
 				bc->out_cause=1;
-				misdn_lib_send_event(bc, EVENT_RELEASE);
+
+				if (bc->nt)  {
+					chan_misdn_log(0,bc->port," --> sending_complete so we never match ..\n");
+					misdn_lib_send_event(bc, EVENT_RELEASE_COMPLETE);
+				} else {
+					chan_misdn_log(0,bc->port," --> sending_complete so we never match ..\n");
+					misdn_lib_send_event(bc, EVENT_RELEASE);
+				}
+
 			} else {
 				
 				int ret= misdn_lib_send_event(bc, EVENT_SETUP_ACKNOWLEDGE );
@@ -3632,13 +3697,12 @@
 	}
 	break;
 	case EVENT_DISCONNECT:
+	/*we might not have an ch->ast ptr here anymore*/
 	{
-		
 		struct chan_list *holded_ch=find_holded(cl_te, bc);
 		
-		
-		send_cause2ast(ch->ast,bc);
-
+		if (ch->ast)	
+			send_cause2ast(ch->ast,bc,ch);
 
 		chan_misdn_log(3,bc->port," --> org:%d nt:%d, inbandavail:%d state:%d\n", ch->orginator, bc->nt, misdn_inband_avail(bc), ch->state);
 		if ( ch->orginator==ORG_AST && !bc->nt && misdn_inband_avail(bc) && ch->state != MISDN_CONNECTED) {
@@ -3648,13 +3712,13 @@
 			   alternative number, then play it instead of
 			   immediately releasing the call */
 			chan_misdn_log(0,bc->port, " --> Inband Info Avail, not sending RELEASE\n");
-			ch->state = MISDN_DISCONNECTED;
+			ch->state=MISDN_DISCONNECTED;
 			start_bc_tones(ch);
 			break;
 		}
 		
 		/*Check for holded channel, to implement transfer*/
-		if (holded_ch ) {
+		if (holded_ch && ch->ast ) {
 			if  (ch->state == MISDN_CONNECTED ) {
 				misdn_transfer_bc(ch, holded_ch) ;
 				misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
@@ -3663,14 +3727,7 @@
 		}
 		
 		stop_bc_tones(ch);
-		/*bc->out_cause=16;*/
 		bc->out_cause=-1;
-		
-		/*if (ch->state == MISDN_CONNECTED) 
-		misdn_lib_send_event(bc,EVENT_RELEASE);
-		else
-		misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
-		*/
 		
 		misdn_lib_send_event(bc,EVENT_RELEASE);
 	}
@@ -3699,7 +3756,10 @@
 			/*stop_bc_tones(ch);
 			  release_chan(bc);*/
 			
+			if (!bc->nt) release_chan(bc);
+			
 			misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
+
 		}
 		break;
 	case EVENT_RELEASE_COMPLETE:
@@ -3720,11 +3780,21 @@
 
 		chan_misdn_log(9,bc->port,"TONE_GEN: len:%d\n");
 
+		if (!ast) break;
+
 		if (!ast->generator) break;
-		
+	
+		
+	
 		tmp = ast->generatordata;
 		ast->generatordata = NULL;
 		generate = ast->generator->generate;
+
+		if (tone_len <0 || tone_len > 512 ) {
+			ast_log(LOG_NOTICE, "TONE_GEN: len was %d, set to 128\n",tone_len);
+			tone_len=128;
+		}
+
 		res = generate(ast, tmp, tone_len, tone_len);
 		ast->generatordata = tmp;
 		
@@ -3787,18 +3857,31 @@
 	}
 	break;
 	case EVENT_TIMEOUT:
-
-		misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
-		break;
 		{
-			switch (ch->state) {
+		if (ch && bc)
+			chan_misdn_log(1,bc->port,"--> state: %s\n",misdn_get_ch_state(ch));
+
+		switch (ch->state) {
+			case MISDN_WAITING4DIGS:
 			case MISDN_CALLING:
-
-				chan_misdn_log(-1, bc?bc->port:0, "GOT TIMOUT AT CALING pid:%d\n", bc?bc->pid:-1);
-					break;
 			case MISDN_DIALING:
 			case MISDN_PROGRESS:
-				break;
+			case MISDN_ALERTING:
+			case MISDN_PROCEEDING:
+			case MISDN_CALLING_ACKNOWLEDGE:
+				if (bc->nt) {
+					bc->progress_indicator=8;
+					tone_indicate(ch, TONE_BUSY);
+				}
+				
+				bc->out_cause=1;
+				misdn_lib_send_event(bc,EVENT_DISCONNECT);
+			break;
+
+			case MISDN_CLEANING: 
+				chan_misdn_log(1,bc->port," --> in state cleaning .. so ingoring, the stack should clean it for us\n");
+			break;
+
 			default:
 				misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
 			}
@@ -3882,7 +3965,7 @@
 			
 			if (bridged && MISDN_ASTERISK_TECH_PVT(bridged)) {
 				ch=MISDN_ASTERISK_TECH_PVT(bridged);
-				//ch->state=MISDN_FACILITY_DEFLECTED;
+				/*ch->state=MISDN_FACILITY_DEFLECTED;*/
 				if (ch->bc) {
 					/* todo */
 				}
@@ -3906,7 +3989,7 @@
 		break;
 				
 	default:
-		ast_log(LOG_WARNING, "Got Unknown Event\n");
+		ast_log(LOG_NOTICE, "Got Unknown Event\n");
 		break;
 	}
 	

Modified: team/crichter/0.4.0/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/chan_sip.c?rev=36083&r1=36082&r2=36083&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/chan_sip.c (original)
+++ team/crichter/0.4.0/channels/chan_sip.c Mon Jun 26 12:48:55 2006
@@ -9371,7 +9371,7 @@
 	if (!strcasecmp(colname, "ip")) {
 		ast_copy_string(buf, peer->addr.sin_addr.s_addr ? ast_inet_ntoa(iabuf, sizeof(iabuf), peer->addr.sin_addr) : "", len);
 	} else  if (!strcasecmp(colname, "status")) {
-		peer_status(peer, buf, sizeof(buf));
+		peer_status(peer, buf, len);
 	} else  if (!strcasecmp(colname, "language")) {
 		ast_copy_string(buf, peer->language, len);
 	} else  if (!strcasecmp(colname, "regexten")) {
@@ -9591,14 +9591,16 @@
 
 	switch (resp) {
 	case 100:	/* Trying */
-		sip_cancel_destroy(p);
+		if (!ignore)
+			sip_cancel_destroy(p);
 		/* must call check_pendings before setting CAN_BYE, so that
 		   if PENDINGBYE is set it will know to send CANCEL instead */
 		check_pendings(p);
 		ast_set_flag(p, SIP_CAN_BYE);
 		break;
 	case 180:	/* 180 Ringing */
-		sip_cancel_destroy(p);
+		if (!ignore)
+			sip_cancel_destroy(p);
 		if (!ignore && p->owner) {
 			ast_queue_control(p->owner, AST_CONTROL_RINGING);
 			if (p->owner->_state != AST_STATE_UP)
@@ -9617,7 +9619,8 @@
 		ast_set_flag(p, SIP_CAN_BYE);
 		break;
 	case 183:	/* Session progress */
-		sip_cancel_destroy(p);
+		if (!ignore)
+			sip_cancel_destroy(p);
 		/* Ignore 183 Session progress without SDP */
 		if (find_sdp(req)) {
 			process_sdp(p, req);
@@ -9632,7 +9635,8 @@
 		ast_set_flag(p, SIP_CAN_BYE);
 		break;
 	case 200:	/* 200 OK on invite - someone's answering our call */
-		sip_cancel_destroy(p);
+		if (!ignore)
+			sip_cancel_destroy(p);
 		p->authtries = 0;
 		if (find_sdp(req)) {
 			process_sdp(p, req);
@@ -10090,7 +10094,8 @@
 					ast_set_flag(p, SIP_NEEDDESTROY);	
 			} else if ((resp >= 100) && (resp < 200)) {
 				if (sipmethod == SIP_INVITE) {
-					sip_cancel_destroy(p);
+					if (!ignore)
+						sip_cancel_destroy(p);
 					if (find_sdp(req))
 						process_sdp(p, req);
 					if (p->owner) {
@@ -10150,9 +10155,9 @@
 			break;
 		default:	/* Errors without handlers */
 			if ((resp >= 100) && (resp < 200)) {
-				if (sipmethod == SIP_INVITE) {	/* re-invite */
+				if (sipmethod == SIP_INVITE && !ignore) 	/* re-invite */
 					sip_cancel_destroy(p);
-				}
+				
 			}
 			if ((resp >= 300) && (resp < 700)) {
 				if ((option_verbose > 2) && (resp != 487))
@@ -10163,7 +10168,7 @@
 				case 500: /* Server error */
 				case 503: /* Service Unavailable */
 
-					if (sipmethod == SIP_INVITE) {	/* re-invite failed */
+					if (sipmethod == SIP_INVITE && !ignore) {	/* re-invite failed */
 						sip_cancel_destroy(p);
 					}
 					break;
@@ -10665,9 +10670,9 @@
 		strcpy(p->context, default_context);
 	res = get_refer_info(p, req);
 	if (res < 0)
-		transmit_response_with_allow(p, "404 Not Found", req, 1);
+		transmit_response(p, "603 Declined", req);
 	else if (res > 0)
-		transmit_response_with_allow(p, "484 Address Incomplete", req, 1);
+		transmit_response(p, "484 Address Incomplete", req);
 	else {
 		int nobye = 0;
 		if (!ignore) {
@@ -10719,6 +10724,7 @@
 	}
 	return res;
 }
+
 /*! \brief  handle_request_cancel: Handle incoming CANCEL request ---*/
 static int handle_request_cancel(struct sip_pvt *p, struct sip_request *req, int debug, int ignore)
 {
@@ -11329,7 +11335,7 @@
 		if (recordhistory) {
 			char tmp[80];
 			/* This is a response, note what it was for */
-			snprintf(tmp, sizeof(tmp), "%s / %s", req.data, get_header(&req, "CSeq"));
+			snprintf(tmp, sizeof(tmp), "%s / %s /%s", req.data, get_header(&req, "CSeq"), req.rlPart2);
 			append_history(p, "Rx", tmp);
 		}
 		nounlock = 0;

Modified: team/crichter/0.4.0/channels/misdn/ie.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/misdn/ie.c?rev=36083&r1=36082&r2=36083&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/misdn/ie.c (original)
+++ team/crichter/0.4.0/channels/misdn/ie.c Mon Jun 26 12:48:55 2006
@@ -1093,8 +1093,7 @@
 	*location = p[1] & 0x0f;
 	*progress = p[2] & 0x7f;
 
-	//if (MISDN_IE_DEBG) printf("    coding=%d location=%d progress=%d\n", *coding, *location, *progress);
-	if (1) printf("    coding=%d location=%d progress=%d\n", *coding, *location, *progress);
+	if (MISDN_IE_DEBG) printf("    coding=%d location=%d progress=%d\n", *coding, *location, *progress);
 }
 
 

Modified: team/crichter/0.4.0/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/channels/misdn/isdn_lib.c?rev=36083&r1=36082&r2=36083&view=diff
==============================================================================
--- team/crichter/0.4.0/channels/misdn/isdn_lib.c (original)
+++ team/crichter/0.4.0/channels/misdn/isdn_lib.c Mon Jun 26 12:48:55 2006
@@ -33,6 +33,20 @@
 	return -1;
 }
 
+int misdn_lib_get_maxchans(int port) 
+{
+	struct misdn_stack *stack=get_misdn_stack();
+	for ( ; stack; stack=stack->next) {
+		if (stack->port == port) {
+			if (stack->pri) 
+				return 30;
+			else
+				return 2;
+		}
+	}
+	return -1;
+}
+
 
 struct misdn_stack* get_stack_by_bc(struct misdn_bchannel *bc)
 {
@@ -61,7 +75,7 @@
 	
 	if (stack) {
 		sprintf(buf, "* Stack Addr:%x Port %d Type %s Prot. %s L2Link %s L1Link:%s", stack->upper_id, stack->port, stack->nt?"NT":"TE", stack->ptp?"PTP":"PMP", stack->l2link?"UP":"DOWN", stack->l1link?"UP":"DOWN");
-		
+
 	} else {
 		buf[0]=0;
 	}
@@ -329,7 +343,7 @@
 }
 
 
-static int mypid=0;
+static int mypid=1;
 
 
 int misdn_cap_is_speech(int cap)
@@ -363,7 +377,7 @@
 	int i;
 
 	for (i=0; i <stack->b_num; i++) {
-		cb_log(8, stack->port, "Idx:%d stack->cchan:%d Chan:%d\n",i,stack->channels[i], i+1);
+		cb_log(6, stack->port, "Idx:%d stack->cchan:%d Chan:%d\n",i,stack->channels[i], i+1);
 	}
 }
 
@@ -373,6 +387,8 @@
 static int find_free_chan_in_stack(struct misdn_stack *stack, struct misdn_bchannel *bc, int channel)
 {
 	int i;
+
+	cb_log(1,stack->port,"find_free_chan: req_chan:%d\n",channel);
 
 	if (channel < 0 || channel > MAX_BCHANS) {
 		cb_log(4, stack->port, " !! out of bound call to find_free_chan_in_stack! (ch:%d)\n", channel);
@@ -384,7 +400,7 @@
 	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 (4, stack->port, " --> found chan%s: %d\n", channel>=0?" (preselected)":"", i+1);
+				cb_log (1, stack->port, " --> found chan%s: %d\n", channel>=0?" (preselected)":"", i+1);
 				stack->channels[i] = 1;
 				bc->channel=i+1;

[... 995 lines stripped ...]


More information about the svn-commits mailing list