[asterisk-commits] branch crichter/frame-data - r7612 in /team/crichter/frame-data: channels/ ch...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Dec 23 03:59:42 CST 2005


Author: crichter
Date: Fri Dec 23 03:59:38 2005
New Revision: 7612

URL: http://svn.digium.com/view/asterisk?rev=7612&view=rev
Log:
chan_zap: 
	* added application ZapSetHDLC to enable HDLC mode when digital
	* added h option in dialstring to enable outgoing HDLC Setting (doesn't work proper yet)

chan_misdn:
	* fixed some digital bchannel setup issues

frame.h:	
	* added AST_FRAME_DATA and some subclasses 


Modified:
    team/crichter/frame-data/channels/chan_zap.c
    team/crichter/frame-data/channels/misdn/isdn_lib.c
    team/crichter/frame-data/include/asterisk/frame.h

Modified: team/crichter/frame-data/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/crichter/frame-data/channels/chan_zap.c?rev=7612&r1=7611&r2=7612&view=diff
==============================================================================
--- team/crichter/frame-data/channels/chan_zap.c (original)
+++ team/crichter/frame-data/channels/chan_zap.c Fri Dec 23 03:59:38 2005
@@ -553,6 +553,7 @@
 	unsigned int dialednone:1;
 	unsigned int dialing:1;
 	unsigned int digital:1;
+	unsigned int hdlc:1;
 	unsigned int dnd:1;
 	unsigned int echobreak:1;
 	unsigned int echocanbridged:1;
@@ -2259,6 +2260,48 @@
 	return 0;
 }
 
+
+
+
+
+
+
+
+static char *zap_set_hdlc_app = "ZapSetHDLC";
+
+static char *zap_set_hdlc_synopsis = "Sets channel into HDLC mode";
+
+static char *zap_set_hdlc_descrip = 
+"  ZapSetHDLC(): This application will set the current channel in hdlc mode\n"
+;
+
+static int zap_set_hdlc_exec(struct ast_channel *chan, void *data)
+{
+	/* Data will be our digit string */
+	struct zt_pvt *p = (struct zt_pvt *)chan->tech_pvt;
+	int x=1;
+	
+	if (!p) {
+		ast_log(LOG_WARNING, "Unable to find technology private\n");
+		return -1;
+	}
+
+	ast_mutex_lock(&p->lock);
+	
+	if (ioctl(p->subs[SUB_REAL].zfd, ZT_HDLCFCSMODE, &x) == -1)
+		ast_log(LOG_WARNING, "Unable to set audio mode on channel %d to %d\n", p->channel, x);
+	
+	p->hdlc=1;
+	
+	ast_mutex_unlock(&p->lock);
+	
+	return 0;
+}
+
+
+
+
+
 int pri_is_up(struct zt_pri *pri)
 {
 	int x;
@@ -2502,7 +2545,16 @@
 			ast_dsp_free(p->dsp);
 			p->dsp = NULL;
 		}
-
+		
+		if (p->hdlc) {
+			int x=1;
+			res = ioctl(p->subs[SUB_REAL].zfd, ZT_AUDIOMODE, &x);
+			if (res < 0) 
+				ast_log(LOG_WARNING, "Unable to set Audiomode on channel %d to default\n", p->channel);
+			p->hdlc = 0;
+		}
+
+		
 		law = ZT_LAW_DEFAULT;
 		res = ioctl(p->subs[SUB_REAL].zfd, ZT_SETLAW, &law);
 		if (res < 0) 
@@ -4547,15 +4599,26 @@
 		ast_mutex_unlock(&p->lock);
 		return f;
 	}
-	if (res != (p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE)) {
-		ast_log(LOG_DEBUG, "Short read (%d/%d), must be an event...\n", res, p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE);
-		f = __zt_exception(ast);
-		ast_mutex_unlock(&p->lock);
-		return f;
+	
+	if (p->digital && p->hdlc ) {
+		/*FIXME:why*/
+		res-=2;
+#if 0
+		ast_log(LOG_NOTICE,"READ: %d\n",res);
+#endif
+	} else {
+		
+		if (res != (p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE)) {
+			ast_log(LOG_DEBUG, "Short read (%d/%d), must be an event...\n", res, p->subs[index].linear ? READ_SIZE * 2 : READ_SIZE);
+			f = __zt_exception(ast);
+			ast_mutex_unlock(&p->lock);
+			return f;
+		}
+
 	}
 	if (p->tdd) { /* if in TDD mode, see if we receive that */
 		int c;
-
+		
 		c = tdd_feed(p->tdd,readbuf,READ_SIZE);
 		if (c < 0) {
 			ast_log(LOG_DEBUG,"tdd_feed failed\n");
@@ -4574,6 +4637,8 @@
 			return &p->subs[index].f;
 		}
 	}
+	
+	
 	if (p->callwaitingrepeat)
 		p->callwaitingrepeat--;
 	if (p->cidcwexpire)
@@ -4589,11 +4654,16 @@
 			ast_verbose(VERBOSE_PREFIX_3 "CPE does not support Call Waiting Caller*ID.\n");
 		restore_conference(p);
 	}
-	if (p->subs[index].linear) {
-		p->subs[index].f.datalen = READ_SIZE * 2;
-	} else 
-		p->subs[index].f.datalen = READ_SIZE;
-
+	
+	if (p->digital && p->hdlc) {
+		p->subs[index].f.datalen = res;
+	} else {
+		if (p->subs[index].linear) {
+			p->subs[index].f.datalen = READ_SIZE * 2;
+		} else 
+			p->subs[index].f.datalen = READ_SIZE;
+	}
+	
 	/* Handle CallerID Transmission */
 	if ((p->owner == ast) && p->cidspill &&((ast->_state == AST_STATE_UP) || (ast->rings == p->cidrings))) {
 		send_callerid(p);
@@ -4601,7 +4671,8 @@
 
 	p->subs[index].f.frametype = AST_FRAME_VOICE;
 	p->subs[index].f.subclass = ast->rawreadformat;
-	p->subs[index].f.samples = READ_SIZE;
+	if (p->digital && p->hdlc )
+		p->subs[index].f.samples = res;
 	p->subs[index].f.mallocd = 0;
 	p->subs[index].f.offset = AST_FRIENDLY_OFFSET;
 	p->subs[index].f.data = p->subs[index].buffer + AST_FRIENDLY_OFFSET/2;
@@ -4622,7 +4693,7 @@
 		p->subs[index].f.data = NULL;
 		p->subs[index].f.datalen= 0;
 	}
-	if (p->dsp && (!p->ignoredtmf || p->callwaitcas || p->busydetect  || p->callprogress) && !index) {
+	if (p->dsp && (!p->ignoredtmf || p->callwaitcas || p->busydetect  || p->callprogress) && !index && !p->digital) {
 		/* Perform busy detection. etc on the zap line */
 		f = ast_dsp_process(ast, p->dsp, &p->subs[index].f);
 		if (f) {
@@ -4724,6 +4795,20 @@
 	int res;
 	int fd;
 	fd = p->subs[index].zfd;
+	
+		
+	if (p->digital && p->hdlc) {
+		/*FIXME: why*/
+		char mybuf[len+2];
+		memcpy(mybuf,buf,len);
+#if 0
+		ast_log(LOG_NOTICE, "Writing on zap channel  len:%d\n",len);
+#endif
+
+		write(fd,mybuf,len+2);
+		return 0;
+	} 
+	
 	while(len) {
 		size = len;
 		if (size > (linear ? READ_SIZE * 2 : READ_SIZE))
@@ -7653,6 +7738,15 @@
 				} else if (opt == 'd') {
 					/* If this is an ISDN call, make it digital */
 					p->digital = 1;
+					if (tmp)
+						tmp->transfercapability = AST_TRANS_CAP_DIGITAL;
+				} else if (opt == 'h') {
+					/* If this is an ISDN call, make it digital + hdlc */
+					ast_log(LOG_NOTICE,"Setting Digital mode with hdlc encryption\n");
+					
+					p->digital = 1;
+					p->hdlc = 1;
+					
 					if (tmp)
 						tmp->transfercapability = AST_TRANS_CAP_DIGITAL;
 				} else {
@@ -8808,11 +8902,16 @@
 						if (!ast_strlen_zero(e->answer.useruserinfo)) {
 							pbx_builtin_setvar_helper(pri->pvts[chanpos]->owner, "USERUSERINFO", e->answer.useruserinfo);
 						}
+						
+						if (pri->pvts[chanpos]->digital && pri->pvts[chanpos]->hdlc) {
+							
+							//zap_set_hdlc_exec(pri->pvts[chanpos]->owner,NULL);
+						} 
 						ast_mutex_unlock(&pri->pvts[chanpos]->lock);
 					}
 				}
 				break;				
-			case PRI_EVENT_HANGUP:
+				case PRI_EVENT_HANGUP:
 				chanpos = pri_find_principle(pri, e->hangup.channel);
 				if (chanpos < 0) {
 					ast_log(LOG_WARNING, "Hangup requested on unconfigured channel %d/%d span %d\n", 
@@ -10032,6 +10131,7 @@
 	}
 	ast_cli_unregister_multiple(zap_pri_cli, sizeof(zap_pri_cli) / sizeof(zap_pri_cli[0]));
 	ast_unregister_application(zap_send_keypad_facility_app);
+	ast_unregister_application(zap_set_hdlc_app);
 #endif
 #ifdef ZAPATA_R2
 	ast_cli_unregister_multiple(zap_r2_cli, sizeof(zap_r2_cli) / sizeof(zap_r2_cli[0]));
@@ -10923,6 +11023,9 @@
 	pri_set_message(zt_pri_message);
 	ast_register_application(zap_send_keypad_facility_app, zap_send_keypad_facility_exec,
 			zap_send_keypad_facility_synopsis, zap_send_keypad_facility_descrip);
+	
+	ast_register_application(zap_set_hdlc_app, zap_set_hdlc_exec,
+				 zap_set_hdlc_synopsis, zap_set_hdlc_descrip);
 #endif
 	res = setup_zap(0);
 	/* Make sure we can register our Zap channel type */

Modified: team/crichter/frame-data/channels/misdn/isdn_lib.c
URL: http://svn.digium.com/view/asterisk/team/crichter/frame-data/channels/misdn/isdn_lib.c?rev=7612&r1=7611&r2=7612&view=diff
==============================================================================
--- team/crichter/frame-data/channels/misdn/isdn_lib.c (original)
+++ team/crichter/frame-data/channels/misdn/isdn_lib.c Fri Dec 23 03:59:38 2005
@@ -756,11 +756,6 @@
 	int midev=stack->midev;
 	int channel=bc->channel-1-(bc->channel>16);
 	int b_stid=stack->b_stids[channel>=0?channel:0];
-	
-	
-	if ( !misdn_cap_is_speech(bc->capability))
-		clean_up_bc(bc);
-	
 	
 	if (bc->upset) {
 		cb_log(4, stack->port, "$$$ bc already upsetted stid :%x\n", b_stid);
@@ -1299,10 +1294,10 @@
 				}
 			} 
 			
-			if (!stack->nt) {
+			if (!stack->nt && misdn_cap_is_speech(bc->capability)) {
 				int ret=setup_bc(bc);
 				if (ret == -EINVAL){
-
+					
 					cb_log(-1,bc->port,"handle_event: setup_bc failed\n");
 					misdn_lib_send_event(bc,EVENT_RELEASE_COMPLETE);
 				}

Modified: team/crichter/frame-data/include/asterisk/frame.h
URL: http://svn.digium.com/view/asterisk/team/crichter/frame-data/include/asterisk/frame.h?rev=7612&r1=7611&r2=7612&view=diff
==============================================================================
--- team/crichter/frame-data/include/asterisk/frame.h (original)
+++ team/crichter/frame-data/include/asterisk/frame.h Fri Dec 23 03:59:38 2005
@@ -147,6 +147,15 @@
 #define AST_FRAME_CNG		10
 /*! T.38 Fax-over-IP data stream */
 #define AST_FRAME_T38		11
+/*! HDLC or non-HDLC encoded Datastream which can be transported over an
+    ISDN call */
+#define AST_FRAME_DATA		12
+
+/* Data Subclass */ 
+/*! HDLC inside */
+#define AST_DATA_HDLC		1
+/*! Bit Order (like Asterisks?)	*/
+#define AST_DATA_ASTBITS	2
 
 /* HTML subclasses */
 /*! Sending a URL */



More information about the asterisk-commits mailing list