[asterisk-commits] nadi: branch group/trunk-cm-csel-hash r47745 - /team/group/trunk-cm-csel-hash...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Nov 16 09:55:00 MST 2006


Author: nadi
Date: Thu Nov 16 10:55:00 2006
New Revision: 47745

URL: http://svn.digium.com/view/asterisk?view=rev&rev=47745
Log:
misdn_ch -> misdn_pvt

Modified:
    team/group/trunk-cm-csel-hash/channels/chan_misdn.c

Modified: team/group/trunk-cm-csel-hash/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/group/trunk-cm-csel-hash/channels/chan_misdn.c?view=diff&rev=47745&r1=47744&r2=47745
==============================================================================
--- team/group/trunk-cm-csel-hash/channels/chan_misdn.c (original)
+++ team/group/trunk-cm-csel-hash/channels/chan_misdn.c Thu Nov 16 10:55:00 2006
@@ -161,7 +161,7 @@
 	enum event_log_elements additional;
 };
 
-struct misdn_ch {
+struct misdn_pvt {
 	struct statemachine *sm;
 	
 	char allowed_bearers[BUFFERSIZE];
@@ -205,12 +205,12 @@
 	char context[BUFFERSIZE];
 	int dropped_frame_cnt;
 	int other_pid;
-	struct misdn_ch *other_ch;
+	struct misdn_pvt *other_pvt;
 	const struct tone_zone_sound *ts;
 
 	int destroy_me;
 
-	AST_RWLIST_ENTRY(misdn_ch) next;
+	AST_RWLIST_ENTRY(misdn_pvt) next;
 };
 
 struct allowed_bearer {
@@ -247,7 +247,7 @@
 static int                    g_config_initialized = 0;
 static int                    glob_channel = 0;
 
-static AST_RWLIST_HEAD_STATIC(ch_list, misdn_ch);
+static AST_RWLIST_HEAD_STATIC(pvt_list, misdn_pvt);
 
 static char                ** misdn_key_vector = NULL;
 static int                    misdn_key_vector_size = 0;
@@ -428,7 +428,7 @@
 			"\tinstead." },
 	{ "senddtmf", "no",
 		"Enable this if we should produce DTMF Tones ourselves." },
-	{ "hold_allowed", "no",
+	{ "hold_allowed", "yes",
 		"Enable this to have support for hold and retrieve." },
 	{ "early_bconnect", "yes",
 		"Disable this if you don't mind correct handling of Progress Indicators." },
@@ -667,30 +667,30 @@
 }
 
 /* Statemachine */
-static struct statemachine_handle_retval handle_aevent_hangup (void *p, int state, int event);
-static struct statemachine_handle_retval handle_mevent_setup (void *p, int state, int event);
-static struct statemachine_handle_retval handle_mevent_setup_followup (void *p, int state, int event);
-static struct statemachine_handle_retval handle_mevent_information (void *p, int state, int event);
-static struct statemachine_handle_retval handle_mevent_information_dtmf (void *p, int state, int event);
-static struct statemachine_handle_retval handle_mevent_setup_acknowledge (void *p, int state, int event);
-static struct statemachine_handle_retval handle_mevent_connect (void *p, int state, int event);
-static struct statemachine_handle_retval handle_mevent_disconnect (void *p, int state, int event);
-static struct statemachine_handle_retval handle_mevent_proceeding_progress (void *p, int state, int event);
-static struct statemachine_handle_retval handle_mevent_port_alarm (void *p, int state, int event);
-static struct statemachine_handle_retval handle_mevent_new_channel (void *p, int state, int event);
-static struct statemachine_handle_retval handle_mevent_new_l3id (void *p, int state, int event);
-static struct statemachine_handle_retval handle_mevent_dtmf_tone (void *p, int state, int event);
-static struct statemachine_handle_retval handle_mevent_alerting (void *p, int state, int event);
-static struct statemachine_handle_retval handle_mevent_connect_acknowledge (void *p, int state, int event);
-static struct statemachine_handle_retval handle_mevent_release (void *p, int state, int event);
-static struct statemachine_handle_retval handle_mevent_release_complete (void *p, int state, int event);
-static struct statemachine_handle_retval handle_mevent_cleanup (void *p, int state, int event);
-static struct statemachine_handle_retval handle_mevent_facility (void *p, int state, int event);
-static struct statemachine_handle_retval handle_mevent_retrieve (void *p, int state, int event);
-static struct statemachine_handle_retval handle_mevent_restart (void *p, int state, int event);
-static struct statemachine_handle_retval handle_mevent_hold (void *p, int state, int event);
-static struct statemachine_handle_retval handle_mevent_timeout_1 (void *p, int state, int event);
-static struct statemachine_handle_retval handle_mevent_timeout_2 (void *p, int state, int event);
+static struct statemachine_handle_retval handle_aevent_hangup (void *pvt, int state, int event);
+static struct statemachine_handle_retval handle_mevent_setup (void *pvt, int state, int event);
+static struct statemachine_handle_retval handle_mevent_setup_followup (void *pvt, int state, int event);
+static struct statemachine_handle_retval handle_mevent_information (void *pvt, int state, int event);
+static struct statemachine_handle_retval handle_mevent_information_dtmf (void *pvt, int state, int event);
+static struct statemachine_handle_retval handle_mevent_setup_acknowledge (void *pvt, int state, int event);
+static struct statemachine_handle_retval handle_mevent_connect (void *pvt, int state, int event);
+static struct statemachine_handle_retval handle_mevent_disconnect (void *pvt, int state, int event);
+static struct statemachine_handle_retval handle_mevent_proceeding_progress (void *pvt, int state, int event);
+static struct statemachine_handle_retval handle_mevent_port_alarm (void *pvt, int state, int event);
+static struct statemachine_handle_retval handle_mevent_new_channel (void *pvt, int state, int event);
+static struct statemachine_handle_retval handle_mevent_new_l3id (void *pvt, int state, int event);
+static struct statemachine_handle_retval handle_mevent_dtmf_tone (void *pvt, int state, int event);
+static struct statemachine_handle_retval handle_mevent_alerting (void *pvt, int state, int event);
+static struct statemachine_handle_retval handle_mevent_connect_acknowledge (void *pvt, int state, int event);
+static struct statemachine_handle_retval handle_mevent_release (void *pvt, int state, int event);
+static struct statemachine_handle_retval handle_mevent_release_complete (void *pvt, int state, int event);
+static struct statemachine_handle_retval handle_mevent_cleanup (void *pvt, int state, int event);
+static struct statemachine_handle_retval handle_mevent_facility (void *pvt, int state, int event);
+static struct statemachine_handle_retval handle_mevent_retrieve (void *pvt, int state, int event);
+static struct statemachine_handle_retval handle_mevent_restart (void *pvt, int state, int event);
+static struct statemachine_handle_retval handle_mevent_hold (void *pvt, int state, int event);
+static struct statemachine_handle_retval handle_mevent_timeout_1 (void *pvt, int state, int event);
+static struct statemachine_handle_retval handle_mevent_timeout_2 (void *pvt, int state, int event);
 
 static struct statemachine_transition misdn_state_table[] = {
 	/*
@@ -878,7 +878,7 @@
 	return misdn_chan_states[state];
 }
 
-static inline void event_info_string (char *buf, int bufsize, struct misdn_ch *ch, int *elems, int num)
+static inline void event_info_string (char *buf, int bufsize, struct misdn_pvt *p, int *elems, int num)
 {
 	int first = 0;
 	char tmpbuf[256];
@@ -896,37 +896,37 @@
 			return; \
 	}
 
-	IF_INFO(L_PID, "pid:%d", ch->bc->pid);
-	IF_INFO(L_CHANNEL, "ch:%d", ch->bc->channel);
-	IF_INFO(L_OAD, "oad:%s", ch->bc->oad);
-	IF_INFO(L_DAD, "dad:%s", ch->bc->dad);
-	IF_INFO(L_CAD, "cad:%s", ch->bc->cad);
-	IF_INFO(L_RAD, "rad:%s", ch->bc->rad);
-	IF_INFO(L_MODE, "mode:%s", ch->bc->nt ? "nt" : "te");
-	IF_INFO(L_CAUSE, "cause:%d", ch->bc->cause);
-	IF_INFO(L_OCAUSE, "out_cause:%d", ch->bc->out_cause);
-	IF_INFO(L_DNUMPLAN, "dnumplan:%d", ch->bc->dnumplan);
-	IF_INFO(L_RNUMPLAN, "rnumplan:%d", ch->bc->rnumplan);
-	IF_INFO(L_CPNNUMPLAN, "cpnnumplan:%d", ch->bc->cpnnumplan);
-	IF_INFO(L_INFODAD, "infodad:%s", ch->bc->info_dad);
-	IF_INFO(L_PRES, "pres:%d", ch->bc->pres);
-	IF_INFO(L_SCREEN, "screen:%d", ch->bc->screen);
-	IF_INFO(L_STATE, "state:%s", get_state_string(statemachine_get_state(ch->sm)));
-	IF_INFO(L_BCSTATE, "bc_state:%s", bc_state2str(ch->bc->bc_state));
-	IF_INFO(L_CONTEXT, "ctx:%s", ch->context);
-}
-
-static void log_event (void *p, int direction, int state, int event)
-{
-	struct misdn_ch *ch = p;
+	IF_INFO(L_PID, "pid:%d", p->bc->pid);
+	IF_INFO(L_CHANNEL, "ch:%d", p->bc->channel);
+	IF_INFO(L_OAD, "oad:%s", p->bc->oad);
+	IF_INFO(L_DAD, "dad:%s", p->bc->dad);
+	IF_INFO(L_CAD, "cad:%s", p->bc->cad);
+	IF_INFO(L_RAD, "rad:%s", p->bc->rad);
+	IF_INFO(L_MODE, "mode:%s", p->bc->nt ? "nt" : "te");
+	IF_INFO(L_CAUSE, "cause:%d", p->bc->cause);
+	IF_INFO(L_OCAUSE, "out_cause:%d", p->bc->out_cause);
+	IF_INFO(L_DNUMPLAN, "dnumplan:%d", p->bc->dnumplan);
+	IF_INFO(L_RNUMPLAN, "rnumplan:%d", p->bc->rnumplan);
+	IF_INFO(L_CPNNUMPLAN, "cpnnumplan:%d", p->bc->cpnnumplan);
+	IF_INFO(L_INFODAD, "infodad:%s", p->bc->info_dad);
+	IF_INFO(L_PRES, "pres:%d", p->bc->pres);
+	IF_INFO(L_SCREEN, "screen:%d", p->bc->screen);
+	IF_INFO(L_STATE, "state:%s", get_state_string(statemachine_get_state(p->sm)));
+	IF_INFO(L_BCSTATE, "bc_state:%s", bc_state2str(p->bc->bc_state));
+	IF_INFO(L_CONTEXT, "ctx:%s", p->context);
+}
+
+static void log_event (void *pvt, int direction, int state, int event)
+{
+	struct misdn_pvt *p = pvt;
 	const struct event_log_info *info = get_event_info(event);
 	int elems;
 	char buf[1024] = "";
 
 	elems = info->elements;
 	if (elems)
-		event_info_string(buf, sizeof(buf), ch, &elems, 7);
-	chan_misdn_log(1, ch->bc->port, "%c%s %s%s%s%s",
+		event_info_string(buf, sizeof(buf), p, &elems, 7);
+	chan_misdn_log(1, p->bc->port, "%c%s %s%s%s%s",
 				   event > EVENT_NOTHING && event < EVENT_UNKNOWN ? 'I' : '*',
 				   direction == LOG_RECEIVE ? "->" : "<-",
 				   info->name,
@@ -937,15 +937,15 @@
 	elems = info->additional;
 	while (elems) {
 		*buf = 0;
-		event_info_string(buf, sizeof(buf), ch, &elems, 3);
-		chan_misdn_log(1, ch->bc->port, "      %s\n", buf);
-	}
-}
-
-static int send_event (void *p, int event)
-{
-	struct misdn_ch *ch = p;
-	struct misdn_bchannel *bc = ch->bc;
+		event_info_string(buf, sizeof(buf), p, &elems, 3);
+		chan_misdn_log(1, p->bc->port, "      %s\n", buf);
+	}
+}
+
+static int send_event (void *pvt, int event)
+{
+	struct misdn_pvt *p = pvt;
+	struct misdn_bchannel *bc = p->bc;
 	int re = 0;
 
 	if (event > EVENT_NOTHING && event < EVENT_UNKNOWN) {
@@ -953,24 +953,22 @@
 		if (event == EVENT_HOLD_ACKNOWLEDGE) {
 			/* XXX find a better place for this */
 			/* forget the channel now */
-			ch->bc = NULL;
-			ch->hold_info.port = bc->port;
-			ch->hold_info.channel = bc->channel;
+			p->bc = NULL;
 		}
 	} else {
 		switch (event) {
 		case AEVENT_CPROCEEDING:
-			ast_queue_control(ch->ast, AST_CONTROL_PROCEEDING);
+			ast_queue_control(p->ast, AST_CONTROL_PROCEEDING);
 			break;
 		case AEVENT_CPROGRESS:
-			ast_queue_control(ch->ast, AST_CONTROL_PROGRESS);
+			ast_queue_control(p->ast, AST_CONTROL_PROGRESS);
 			break;
 		case AEVENT_CRINGING:
-			ast_queue_control(ch->ast, AST_CONTROL_RINGING);
-			ast_setstate(ch->ast, AST_STATE_RINGING);
+			ast_queue_control(p->ast, AST_CONTROL_RINGING);
+			ast_setstate(p->ast, AST_STATE_RINGING);
 			break;
 		case AEVENT_CANSWER:
-			ast_queue_control(ch->ast, AST_CONTROL_ANSWER);
+			ast_queue_control(p->ast, AST_CONTROL_ANSWER);
 			break;
 		default:
 			re = -1;
@@ -1060,140 +1058,140 @@
 	AST_HASH_DESTROY(&group_csel_hash);
 }
 
-/* misdn_ch Helper */
-static struct misdn_ch * misdn_ch_init (int orig)
-{
-	struct misdn_ch *ch = calloc(1, sizeof(struct misdn_ch));
-
-	if (!ch) {
+/* misdn_pvt Helper */
+static struct misdn_pvt * misdn_pvt_init (int orig)
+{
+	struct misdn_pvt *p = calloc(1, sizeof(struct misdn_pvt));
+
+	if (!p) {
 		chan_misdn_log(-1, 0, "misdn_request: malloc failed!");
 		return NULL;
 	}
 
-	ch->sm = statemachine_create(ch, MISDN_NOTHING, misdn_state_table,
-								 sizeof(misdn_state_table) / sizeof(struct statemachine_transition),
-								 send_event,
-								 log_event);
-	ch->orginator = orig;
-	ch->need_queue_hangup = 1;
-	ch->need_hangup = 1;
-	ch->need_busy = 1;
-	ch->overlap_dial_task = -1;
-
-	return ch;
-}
-
-static void misdn_ch_queue (struct misdn_ch *chan)
-{
-	AST_RWLIST_WRLOCK(&ch_list);
-	AST_RWLIST_INSERT_TAIL(&ch_list, chan, next);
-	AST_RWLIST_UNLOCK(&ch_list);
-}
-
-static void misdn_ch_dequeue (struct misdn_ch *chan) 
-{
-	if (chan->dsp) 
-		ast_dsp_free(chan->dsp);
-
-	if (chan->trans)
-		ast_translator_free_path(chan->trans);
-
-	AST_RWLIST_WRLOCK(&ch_list);
-	AST_RWLIST_REMOVE(&ch_list, chan, next);
-	AST_RWLIST_UNLOCK(&ch_list);
-}
-
-static struct misdn_ch * misdn_ch_by_bc (struct misdn_bchannel *bc)
-{
-	struct misdn_ch *ch;
-
-	AST_RWLIST_RDLOCK(&ch_list);
-	AST_RWLIST_TRAVERSE(&ch_list, ch, next) {
-		if (ch->bc == bc)
+	p->sm = statemachine_create(p, MISDN_NOTHING, misdn_state_table,
+								sizeof(misdn_state_table) / sizeof(struct statemachine_transition),
+								send_event,
+								log_event);
+	p->orginator = orig;
+	p->need_queue_hangup = 1;
+	p->need_hangup = 1;
+	p->need_busy = 1;
+	p->overlap_dial_task = -1;
+
+	return p;
+}
+
+static inline void misdn_pvt_queue (struct misdn_pvt *p)
+{
+	AST_RWLIST_WRLOCK(&pvt_list);
+	AST_RWLIST_INSERT_TAIL(&pvt_list, p, next);
+	AST_RWLIST_UNLOCK(&pvt_list);
+}
+
+static inline void misdn_pvt_dequeue (struct misdn_pvt *p) 
+{
+	if (p->dsp) 
+		ast_dsp_free(p->dsp);
+
+	if (p->trans)
+		ast_translator_free_path(p->trans);
+
+	AST_RWLIST_WRLOCK(&pvt_list);
+	AST_RWLIST_REMOVE(&pvt_list, p, next);
+	AST_RWLIST_UNLOCK(&pvt_list);
+}
+
+static struct misdn_pvt * misdn_pvt_by_bc (struct misdn_bchannel *bc)
+{
+	struct misdn_pvt *p;
+
+	AST_RWLIST_RDLOCK(&pvt_list);
+	AST_RWLIST_TRAVERSE(&pvt_list, p, next) {
+		if (p->bc == bc)
 			break;
 	}
-	AST_RWLIST_UNLOCK(&ch_list);
-
-	if (!ch)
+	AST_RWLIST_UNLOCK(&pvt_list);
+
+	if (!p)
 		chan_misdn_log(6, bc->port, "$$$ find_chan: No channel found for oad:%s dad:%s\n", bc->oad, bc->dad);
 
-	return ch;
-}
-
-static struct misdn_ch * misdn_ch_by_pid (int pid)
-{
-	struct misdn_ch *ch;
-
-	AST_RWLIST_RDLOCK(&ch_list);
-	AST_RWLIST_TRAVERSE(&ch_list, ch, next) {
-		if (ch->bc && ch->bc->pid == pid)
+	return p;
+}
+
+static struct misdn_pvt * misdn_pvt_by_pid (int pid)
+{
+	struct misdn_pvt *p;
+
+	AST_RWLIST_RDLOCK(&pvt_list);
+	AST_RWLIST_TRAVERSE(&pvt_list, p, next) {
+		if (p->bc && p->bc->pid == pid)
 			break;
 	}
-	AST_RWLIST_UNLOCK(&ch_list);
-
-	if (!ch)
+	AST_RWLIST_UNLOCK(&pvt_list);
+
+	if (!p)
 		chan_misdn_log(6, 0, "$$$ find_chan: No channel found for pid:%d\n", pid);
 
-	return ch;
-}
-
-static struct misdn_ch * misdn_ch_by_ast (struct ast_channel *ast)
-{
-	struct misdn_ch *ch;
-
-	AST_RWLIST_RDLOCK(&ch_list);
-	AST_RWLIST_TRAVERSE(&ch_list, ch, next) {
-		if (ch->ast == ast)
+	return p;
+}
+
+static struct misdn_pvt * misdn_pvt_by_ast (struct ast_channel *ast)
+{
+	struct misdn_pvt *p;
+
+	AST_RWLIST_RDLOCK(&pvt_list);
+	AST_RWLIST_TRAVERSE(&pvt_list, p, next) {
+		if (p->ast == ast)
 			break;
 	}
-	AST_RWLIST_UNLOCK(&ch_list);
-
-	return ch;
-}
-
-static struct misdn_ch * misdn_ch_by_ast_name (char *name)
-{
-	struct misdn_ch *ch;
-
-	AST_RWLIST_RDLOCK(&ch_list);
-	AST_RWLIST_TRAVERSE(&ch_list, ch, next) {
-		if (ch->ast && !strcmp(ch->ast->name, name))
+	AST_RWLIST_UNLOCK(&pvt_list);
+
+	return p;
+}
+
+static struct misdn_pvt * misdn_pvt_by_ast_name (char *name)
+{
+	struct misdn_pvt *p;
+
+	AST_RWLIST_RDLOCK(&pvt_list);
+	AST_RWLIST_TRAVERSE(&pvt_list, p, next) {
+		if (p->ast && !strcmp(p->ast->name, name))
 			break;
 	}
-	AST_RWLIST_UNLOCK(&ch_list);
-
-	return ch;
-}
-
-static struct misdn_ch * misdn_ch_holded (struct misdn_bchannel *bc)
-{
-	struct misdn_ch *ch;
-
-	AST_RWLIST_RDLOCK(&ch_list);
-	AST_RWLIST_TRAVERSE(&ch_list, ch, next) {
-		if (statemachine_get_state(ch->sm) == MISDN_HOLDED && ch->hold_info.port == bc->port)
+	AST_RWLIST_UNLOCK(&pvt_list);
+
+	return p;
+}
+
+static struct misdn_pvt * misdn_pvt_holded (struct misdn_bchannel *bc)
+{
+	struct misdn_pvt *p;
+
+	AST_RWLIST_RDLOCK(&pvt_list);
+	AST_RWLIST_TRAVERSE(&pvt_list, p, next) {
+		if (statemachine_get_state(p->sm) == MISDN_HOLDED && p->hold_info.port == bc->port)
 			break;
 	}
-	AST_RWLIST_UNLOCK(&ch_list);
-
-	if (!ch)
+	AST_RWLIST_UNLOCK(&pvt_list);
+
+	if (!p)
 		chan_misdn_log(6, bc->port, "$$$ find_chan: No channel found for oad:%s dad:%s\n", bc->oad, bc->dad);
 
-	return ch;
-}
-
-static struct misdn_ch * misdn_ch_holded_l3 (unsigned long l3_id)
-{
-	struct misdn_ch *ch;
-
-	AST_RWLIST_RDLOCK(&ch_list);
-	AST_RWLIST_TRAVERSE(&ch_list, ch, next) {
-		if (statemachine_get_state(ch->sm) == MISDN_HOLDED && ch->l3id == l3_id) 
+	return p;
+}
+
+static struct misdn_pvt * misdn_pvt_holded_l3 (unsigned long l3_id)
+{
+	struct misdn_pvt *p;
+
+	AST_RWLIST_RDLOCK(&pvt_list);
+	AST_RWLIST_TRAVERSE(&pvt_list, p, next) {
+		if (statemachine_get_state(p->sm) == MISDN_HOLDED && p->l3id == l3_id) 
 			break;
 	}
-	AST_RWLIST_UNLOCK(&ch_list);
+	AST_RWLIST_UNLOCK(&pvt_list);
 	
-	return ch;
+	return p;
 }
 
 /* Jitterbuffer */
@@ -1313,10 +1311,10 @@
 
 static int bc_jb_empty (struct misdn_bchannel *bc, char *buf, int len) 
 {
-	struct misdn_ch *ch = misdn_ch_by_bc(bc);
-
-	if (ch && ch->jb)
-		return misdn_jb_empty(ch->jb, buf, len);
+	struct misdn_pvt *p = misdn_pvt_by_bc(bc);
+
+	if (p && p->jb)
+		return misdn_jb_empty(p->jb, buf, len);
 
 	return -1;
 }
@@ -1490,9 +1488,9 @@
 	}
 }
 
-static void print_bc_info (int fd, struct misdn_ch *ch, struct misdn_bchannel *bc)
-{
-	struct ast_channel *ast = ch->ast;
+static void print_bc_info (int fd, struct misdn_pvt *p, struct misdn_bchannel *bc)
+{
+	struct ast_channel *ast = p->ast;
 
 	ast_cli(fd,
 			"* Pid:%d Prt:%d Ch:%d Mode:%s Org:%s dad:%s oad:%s rad:%s ctx:%s state:%s\n",
@@ -1500,12 +1498,12 @@
 			bc->port,
 			bc->channel,
 			bc->nt ? "NT" : "TE",
-			ch->orginator == ORG_AST ? "*" : "I",
+			p->orginator == ORG_AST ? "*" : "I",
 			ast ? ast->exten : "",
 			ast ? AST_CID_P(ast) : "",
 			bc->rad,
 			ast ? ast->context : "",
-			get_state_string(statemachine_get_state(ch->sm)));
+			get_state_string(statemachine_get_state(p->sm)));
 
 	if (misdn_debug[bc->port] > 0)
 		ast_cli(fd,
@@ -1520,32 +1518,32 @@
 				"  --> echo_cancel: %d\n"
 				"  --> notone : rx %d tx:%d\n"
 				"  --> bc_hold: %d\n",
-				ch->ast->name,
-				ch->l3id,
-				ch->addr,
+				p->ast->name,
+				p->l3id,
+				p->addr,
 				bc->addr,
 				bc->l3_id,
 				bc->display,
 				bc_state2str(bc->bc_state),
 				get_bearer_str(bc->capability),
 				bc->ec_enable,
-				ch->norxtone,
-				ch->notxtone,
+				p->norxtone,
+				p->notxtone,
 				bc->holded);
 }
 
-static void import_ch (struct ast_channel *chan, struct misdn_bchannel *bc, struct misdn_ch *ch)
+static void import_ch (struct ast_channel *chan, struct misdn_bchannel *bc, struct misdn_pvt *p)
 {
 	const char *tmp;
 
 	tmp = pbx_builtin_getvar_helper(chan, "MISDN_PID");
 	if (tmp) {
-		ch->other_pid = atoi(tmp);
+		p->other_pid = atoi(tmp);
 		chan_misdn_log(2, bc->port, "IMPORT_PID: importing pid:%s\n", tmp);
-		if (ch->other_pid > 0) {
-			ch->other_ch = misdn_ch_by_pid(ch->other_pid);
-			if (ch->other_ch)
-				ch->other_ch->other_ch = ch;
+		if (p->other_pid > 0) {
+			p->other_pvt = misdn_pvt_by_pid(p->other_pid);
+			if (p->other_pvt)
+				p->other_pvt->other_pvt = p;
 		}
 	}
 }
@@ -1659,14 +1657,14 @@
 }
 
 /* Channel Helpers */
-static int pbx_start_chan (struct misdn_ch *ch)
-{
-	int ret = ast_pbx_start(ch->ast);	
-	ch->need_hangup = ret >= 0 ? 0 : 1;
+static int pbx_start_chan (struct misdn_pvt *p)
+{
+	int ret = ast_pbx_start(p->ast);	
+	p->need_hangup = ret >= 0 ? 0 : 1;
 	return ret;
 }
 
-static void export_chan (struct ast_channel *chan, struct misdn_bchannel *bc, struct misdn_ch *ch)
+static void export_chan (struct ast_channel *chan, struct misdn_bchannel *bc, struct misdn_pvt *p)
 {
 	char tmp[32];
 	chan_misdn_log(2, bc->port, "EXPORT_PID: pid:%d\n", bc->pid);
@@ -1674,9 +1672,9 @@
 	pbx_builtin_setvar_helper(chan, "_MISDN_PID", tmp);
 }
 
-static void send_digit_to_chan (struct misdn_ch *ch, char digit)
-{
-	struct ast_channel *chan = ch->ast; 
+static void send_digit_to_chan (struct misdn_pvt *p, char digit)
+{
+	struct ast_channel *chan = p->ast; 
 	static const char *dtmf_tones[] = {
 		"!941+1336/100, !0/100",	/* 0 */
 		"!697+1209/100, !0/100",	/* 1 */
@@ -1708,7 +1706,7 @@
 		ast_log(LOG_DEBUG, "Unable to handle DTMF tone '%c' for '%s'\n", digit, chan->name);
 }
 
-static void send_cause_to_ast (struct ast_channel *ast, struct misdn_bchannel *bc, struct misdn_ch *ch)
+static void send_cause_to_ast (struct ast_channel *ast, struct misdn_bchannel *bc, struct misdn_pvt *p)
 {
 	if (!ast) {
 		chan_misdn_log(2, 0, "send_cause_to_ast: No Ast\n");
@@ -1718,7 +1716,7 @@
 		chan_misdn_log(2, 0, "send_cause_to_ast: No BC\n");
 		return;
 	}
-	if (!ch) {
+	if (!p) {
 		chan_misdn_log(2, 0, "send_cause_to_ast: No Ch\n");
 		return;
 	}
@@ -1726,145 +1724,145 @@
 	ast->hangupcause = bc->cause;
 
 	if (bc->cause == 21 || bc->cause == 17) {
-		statemachine_set_state(ch->sm, MISDN_BUSY);
-		if (!ch->need_busy) {
+		statemachine_set_state(p->sm, MISDN_BUSY);
+		if (!p->need_busy) {
 			chan_misdn_log(2, bc->port, "Queued busy already\n");
 		} else {
 			chan_misdn_log(2, bc->port, " --> * SEND: Queue Busy pid:%d\n", bc->pid);
 			ast_queue_control(ast, AST_CONTROL_BUSY);
-			ch->need_busy = 0;
-		}
-	}
-}
-
-static int dialtone_indicate (struct misdn_ch *ch)
+			p->need_busy = 0;
+		}
+	}
+}
+
+static int dialtone_indicate (struct misdn_pvt *p)
 {
 	const struct tone_zone_sound *ts= NULL;
 	int nd = 0;
 
-	if (!cm_get_strcasecmp(misdn_cm, "yes", PORT, MCFG_NODIALTONE, ch->bc->port))
+	if (!cm_get_strcasecmp(misdn_cm, "yes", PORT, MCFG_NODIALTONE, p->bc->port))
 		nd = 1;
 	if (nd) {
-		chan_misdn_log(2, ch->bc->port, "Not sending Dialtone, because config wants it\n");
+		chan_misdn_log(2, p->bc->port, "Not sending Dialtone, because config wants it\n");
 		return 0;
 	}
 
-	chan_misdn_log(3, ch->bc->port, " --> Dial\n");
-	ts = ast_get_indication_tone(ch->ast->zone, "dial");
-	ch->ts = ts;	
+	chan_misdn_log(3, p->bc->port, " --> Dial\n");
+	ts = ast_get_indication_tone(p->ast->zone, "dial");
+	p->ts = ts;	
 
 	if (ts) {
-		ch->notxtone = 0;
-		ch->norxtone = 0;
-		ast_playtones_start(ch->ast, 0, ts->data, 0);
-		chan_misdn_log(4, ch->bc->port, "Starting Playtones\n");
-		misdn_lib_tone_generator_start(ch->bc);
+		p->notxtone = 0;
+		p->norxtone = 0;
+		ast_playtones_start(p->ast, 0, ts->data, 0);
+		chan_misdn_log(4, p->bc->port, "Starting Playtones\n");
+		misdn_lib_tone_generator_start(p->bc);
 	}
 
 	return 0;
 }
 
-static int hanguptone_indicate (struct misdn_ch *ch)
-{
-	misdn_lib_send_tone(ch->bc, TONE_HANGUP);
+static int hanguptone_indicate (struct misdn_pvt *p)
+{
+	misdn_lib_send_tone(p->bc, TONE_HANGUP);
 	return 0;
 }
 
-static int stop_indicate (struct misdn_ch *ch)
-{
-	chan_misdn_log(3, ch->bc->port, " --> None\n");
-	misdn_lib_tone_generator_stop(ch->bc);
-	ast_playtones_stop(ch->ast);
+static int stop_indicate (struct misdn_pvt *p)
+{
+	chan_misdn_log(3, p->bc->port, " --> None\n");
+	misdn_lib_tone_generator_stop(p->bc);
+	ast_playtones_stop(p->ast);
 	return 0;
 }
 
-static int start_bc_tones (struct misdn_ch *ch)
-{
-	misdn_lib_tone_generator_stop(ch->bc);
-	ch->notxtone = 0;
-	ch->norxtone = 0;
+static int start_bc_tones (struct misdn_pvt *p)
+{
+	misdn_lib_tone_generator_stop(p->bc);
+	p->notxtone = 0;
+	p->norxtone = 0;
 	return 0;
 }
 
-static int stop_bc_tones (struct misdn_ch *ch)
-{
-	ch->notxtone = 1;
-	ch->norxtone = 1;
+static int stop_bc_tones (struct misdn_pvt *p)
+{
+	p->notxtone = 1;
+	p->norxtone = 1;
 	return 0;
 }
 
-static void hangup_chan (struct misdn_ch *ch)
+static void hangup_chan (struct misdn_pvt *p)
 {
 	int port;
 
-	if (!ch || !ch->bc) {
-		chan_misdn_log(2, 0, "Cannot hangup chan, no ch or no ch->bc!\n");
+	if (!p || !p->bc) {
+		chan_misdn_log(2, 0, "Cannot hangup chan, no ch or no p->bc!\n");
 		return;
 	}
 	
-	port = ch->bc ? ch->bc->port : 0;
+	port = p->bc ? p->bc->port : 0;
 	chan_misdn_log(2, port, "hangup_chan\n");
 
-	if (ch->need_hangup) {
+	if (p->need_hangup) {
 		chan_misdn_log(2, port, "-> hangup\n");
-		send_cause_to_ast(ch->ast, ch->bc, ch);
-		ch->need_hangup = ch->need_queue_hangup = 0;
-		if (ch->ast)
-			ast_hangup(ch->ast);
+		send_cause_to_ast(p->ast, p->bc, p);
+		p->need_hangup = p->need_queue_hangup = 0;
+		if (p->ast)
+			ast_hangup(p->ast);
 		return;
 	}
 
-	if (!ch->need_queue_hangup) {
+	if (!p->need_queue_hangup) {
 		chan_misdn_log(2, port, "No need to queue hangup\n");
 	}
 
-	ch->need_queue_hangup = 0;
-	if (ch->ast) {
-		send_cause_to_ast(ch->ast, ch->bc, ch);
-		ast_queue_hangup(ch->ast);
+	p->need_queue_hangup = 0;
+	if (p->ast) {
+		send_cause_to_ast(p->ast, p->bc, p);
+		ast_queue_hangup(p->ast);
 		chan_misdn_log(2, port, "-> queue_hangup\n");
 	} else
 		chan_misdn_log(2, port, "Cannot hangup chan, no ast\n");
 }
 
 /* Isdn asks us to release channel, pendant to misdn_hangup */
-static void release_chan (struct misdn_ch *ch)
+static void release_chan (struct misdn_pvt *p)
 {
 	struct ast_channel *ast;
-	struct misdn_bchannel *bc = ch->bc;
-
-	if (!ch) {
+	struct misdn_bchannel *bc = p->bc;
+
+	if (!p) {
 		chan_misdn_log(2, bc->port, "release_chan: No ch!\n");
 		return;
 	}
-	ast = ch->ast;
+	ast = p->ast;
 	chan_misdn_log(2, bc->port, "release_chan: bc with l3id: %x\n", bc->l3_id);
 
-	if (ch->jb) {
-		misdn_jb_destroy(ch->jb);
-		ch->jb = NULL;
+	if (p->jb) {
+		misdn_jb_destroy(p->jb);
+		p->jb = NULL;
 	} else if (!bc->nojitter)
 		chan_misdn_log(5, bc->port, "Jitterbuffer already destroyed.\n");
 
-	if (ch->overlap_dial) {
-		if (ch->overlap_dial_task != -1) {
-			misdn_tasks_remove(ch->overlap_dial_task);
-			ch->overlap_dial_task = -1;
-		}
-		ast_mutex_destroy(&ch->overlap_tv_lock);
-	}
-
-	if (ch->orginator == ORG_AST)
+	if (p->overlap_dial) {
+		if (p->overlap_dial_task != -1) {
+			misdn_tasks_remove(p->overlap_dial_task);
+			p->overlap_dial_task = -1;
+		}
+		ast_mutex_destroy(&p->overlap_tv_lock);
+	}
+
+	if (p->orginator == ORG_AST)
 		--misdn_out_calls[bc->port];
 	else
 		--misdn_in_calls[bc->port];
 
-	close(ch->pipe[0]);
-	close(ch->pipe[1]);
+	close(p->pipe[0]);
+	close(p->pipe[1]);
 
 	if (ast && MISDN_ASTERISK_TECH_PVT(ast)) {
 		chan_misdn_log(2, bc->port, "* RELEASING CHANNEL pid:%d ctx:%s dad:%s oad:%s state: %s\n",
-					   bc->pid, ast->context, ast->exten, AST_CID_P(ast), get_state_string(statemachine_get_state(ch->sm)));
+					   bc->pid, ast->context, ast->exten, AST_CID_P(ast), get_state_string(statemachine_get_state(p->sm)));
 		chan_misdn_log(3, bc->port, " --> * State Down\n");
 		MISDN_ASTERISK_TECH_PVT(ast) = NULL;
 		if (ast->_state != AST_STATE_RESERVED) {
@@ -1873,19 +1871,19 @@
 		}
 	}
 
-	misdn_ch_dequeue(ch);
-	statemachine_destroy(ch->sm);
-	free(ch);
-}
-
-static void misdn_transfer_bc (struct misdn_ch *ch, struct misdn_ch *holded_ch)
-{
-	chan_misdn_log(4, 0, "TRANSFERING %s to %s\n", holded_ch->ast->name, ch->ast->name);
-	statemachine_set_state(ch->sm, MISDN_HOLD_DISCONNECT);
-	ast_moh_stop(AST_BRIDGED_P(holded_ch->ast));
-	statemachine_set_state(holded_ch->sm, MISDN_CONNECTED);
-/* 	misdn_lib_transfer(holded_ch->bc); */
-	ast_channel_masquerade(holded_ch->ast, AST_BRIDGED_P(ch->ast));
+	misdn_pvt_dequeue(p);
+	statemachine_destroy(p->sm);
+	free(p);
+}
+
+static void misdn_transfer_bc (struct misdn_pvt *p, struct misdn_pvt *holded_p)
+{
+	chan_misdn_log(4, 0, "TRANSFERING %s to %s\n", holded_p->ast->name, p->ast->name);
+	statemachine_set_state(p->sm, MISDN_HOLD_DISCONNECT);
+	ast_moh_stop(AST_BRIDGED_P(holded_p->ast));
+	statemachine_set_state(holded_p->sm, MISDN_CONNECTED);
+/* 	misdn_lib_transfer(holded_p->bc); */
+	ast_channel_masquerade(holded_p->ast, AST_BRIDGED_P(p->ast));
 }
 
 static int add_in_calls (int port)
@@ -1929,42 +1927,42 @@
 {
 	struct timeval tv_end, tv_now;
 	int diff;
-	struct misdn_ch *ch = (struct misdn_ch *)data;
-
-	chan_misdn_log(4, ch->bc->port, "overlap dial task, chan_state: %d\n", statemachine_get_state(ch->sm));
-
-	if (statemachine_get_state(ch->sm) != MISDN_WAITING4DIGS) {
-		ch->overlap_dial_task = -1;
+	struct misdn_pvt *p = (struct misdn_pvt *)data;
+
+	chan_misdn_log(4, p->bc->port, "overlap dial task, chan_state: %d\n", statemachine_get_state(p->sm));
+
+	if (statemachine_get_state(p->sm) != MISDN_WAITING4DIGS) {
+		p->overlap_dial_task = -1;
 		return 0;
 	}
 
-	ast_mutex_lock(&ch->overlap_tv_lock);
-	tv_end = ch->overlap_tv;
-	ast_mutex_unlock(&ch->overlap_tv_lock);
-
-	tv_end.tv_sec += ch->overlap_dial;
+	ast_mutex_lock(&p->overlap_tv_lock);
+	tv_end = p->overlap_tv;
+	ast_mutex_unlock(&p->overlap_tv_lock);
+
+	tv_end.tv_sec += p->overlap_dial;
 	tv_now = ast_tvnow();
 
 	diff = ast_tvdiff_ms(tv_end, tv_now);
 
 	if (diff <= 100) {
 		/* if we are 100ms near the timeout, we are satisfied.. */
-		stop_indicate(ch);
-		if (ast_exists_extension(ch->ast, ch->context, ch->bc->dad, 1, ch->bc->oad)) {
-			statemachine_set_state(ch->sm, MISDN_DIALING);
-			if (pbx_start_chan(ch) < 0) {
-				chan_misdn_log(-1, ch->bc->port, "ast_pbx_start returned < 0 in misdn_overlap_dial_task\n");
+		stop_indicate(p);
+		if (ast_exists_extension(p->ast, p->context, p->bc->dad, 1, p->bc->oad)) {
+			statemachine_set_state(p->sm, MISDN_DIALING);
+			if (pbx_start_chan(p) < 0) {
+				chan_misdn_log(-1, p->bc->port, "ast_pbx_start returned < 0 in misdn_overlap_dial_task\n");
 				goto misdn_overlap_dial_task_disconnect;
 			}
 		} else {
 misdn_overlap_dial_task_disconnect:
-			hanguptone_indicate(ch);
-			if (ch->bc->nt)
-				misdn_lib_send_event(ch->bc, EVENT_RELEASE_COMPLETE);
+			hanguptone_indicate(p);
+			if (p->bc->nt)
+				misdn_lib_send_event(p->bc, EVENT_RELEASE_COMPLETE);
 			else
-				misdn_lib_send_event(ch->bc, EVENT_RELEASE);
-		}
-		ch->overlap_dial_task = -1;
+				misdn_lib_send_event(p->bc, EVENT_RELEASE);
+		}
+		p->overlap_dial_task = -1;
 		return 0;
 	}
 
@@ -2017,7 +2015,7 @@
 {
 	char *channame,
 		 *nr; 
-	struct misdn_ch *ch;
+	struct misdn_pvt *p;
 
 	if (argc != 5)
 		return RESULT_SHOWUSAGE;
@@ -2025,17 +2023,17 @@
 	channame = argv[3];
 	nr = argv[4];
 	ast_cli(fd, "Sending Calldeflection (%s) to %s\n", nr, channame);
-	ch = misdn_ch_by_ast_name(channame);
-	if (!ch) {
+	p = misdn_pvt_by_ast_name(channame);
+	if (!p) {
 		ast_cli(fd, "Sending CD with nr %s to %s failed: Channel does not exist.\n", nr, channame);
 	} else {
 		if (strlen(nr) >= 15) {
 			ast_cli(fd, "Sending CD with nr %s to %s failed: Number too long (up to 15 digits are allowed).\n", nr, channame);
 			return 0; 
 		}
-		ch->bc->fac_out.Function = Fac_CD;
-		strncpy((char *)ch->bc->fac_out.u.CDeflection.DeflectedToNumber, nr, sizeof(ch->bc->fac_out.u.CDeflection.DeflectedToNumber));
-		misdn_lib_send_event(ch->bc, EVENT_FACILITY);
+		p->bc->fac_out.Function = Fac_CD;
+		strncpy((char *)p->bc->fac_out.u.CDeflection.DeflectedToNumber, nr, sizeof(p->bc->fac_out.u.CDeflection.DeflectedToNumber));
+		misdn_lib_send_event(p->bc, EVENT_FACILITY);
 	}
 
 	return 0; 
@@ -2045,7 +2043,7 @@
 {
 	char *channame,
 		 *msg; 
-	struct misdn_ch *ch;
+	struct misdn_pvt *p;
 	int i,
 		msglen;
 
@@ -2055,14 +2053,14 @@
 	channame = argv[3];
 	msg = argv[4];
 	ast_cli(fd, "Sending %s to %s\n", msg, channame);
-	ch = misdn_ch_by_ast_name(channame);
-	if (!ch) {
+	p = misdn_pvt_by_ast_name(channame);
+	if (!p) {
 		ast_cli(fd, "Sending %s to %s failed Channel does not exist\n", msg, channame);
 	} else {
 		msglen = strlen(msg);
 		for (i = 0; i < msglen; ++i) {
 			ast_cli(fd, "Sending: %c\n", msg[i]);
-			send_digit_to_chan(ch, msg[i]);
+			send_digit_to_chan(p, msg[i]);
 			usleep(250000);
 		}
 	}
@@ -2073,7 +2071,7 @@
 static int misdn_toggle_echocancel (int fd, int argc, char *argv[])
 {
 	char *channame; 
-	struct misdn_ch *ch;
+	struct misdn_pvt *p;
 
 	if (argc != 4)
 		return RESULT_SHOWUSAGE;
@@ -2081,16 +2079,16 @@
 	channame = argv[3];
 	ast_cli(fd, "Toggling EchoCancel on %s\n", channame);
 
-	ch = misdn_ch_by_ast_name(channame);
-	if (!ch) {
+	p = misdn_pvt_by_ast_name(channame);
+	if (!p) {
 		ast_cli(fd, "Toggling EchoCancel %s failed Channel does not exist\n", channame);
 	} else {
-		ch->toggle_ec = ch->toggle_ec ? 0 : 1;
-		if (ch->toggle_ec) {
-			config_bc_echocancel(ch->bc);
-			manager_ec_enable(ch->bc);
+		p->toggle_ec = p->toggle_ec ? 0 : 1;
+		if (p->toggle_ec) {
+			config_bc_echocancel(p->bc);
+			manager_ec_enable(p->bc);
 		} else {
-			manager_ec_disable(ch->bc);
+			manager_ec_disable(p->bc);
 		}
 	}
 
@@ -2101,7 +2099,7 @@
 {
 	char *channame,
 		 *msg; 
-	struct misdn_ch *ch;
+	struct misdn_pvt *p;
 
 	if (argc != 5)
 		return RESULT_SHOWUSAGE;
@@ -2109,10 +2107,10 @@
 	channame = argv[3];
 	msg = argv[4];
 	ast_cli(fd, "Sending %s to %s\n", msg, channame);
-	ch = misdn_ch_by_ast_name(channame);
-	if (ch && ch->bc) {
-		ast_copy_string(ch->bc->display, msg, sizeof(ch->bc->display));
-		misdn_lib_send_event(ch->bc, EVENT_INFORMATION);
+	p = misdn_pvt_by_ast_name(channame);
+	if (p && p->bc) {
+		ast_copy_string(p->bc->display, msg, sizeof(p->bc->display));
+		misdn_lib_send_event(p->bc, EVENT_INFORMATION);
 	} else {
 		ast_cli(fd, "No such channel %s\n", channame);
 		return RESULT_FAILURE;
@@ -2135,44 +2133,44 @@
 
 static int misdn_show_cls (int fd, int argc, char *argv[])
 {
-	struct misdn_ch *ch;
-
-	AST_RWLIST_RDLOCK(&ch_list);
-	ast_cli(fd, "Chan List:\n");
-	AST_RWLIST_TRAVERSE(&ch_list, ch, next) {
+	struct misdn_pvt *p;
+
+	AST_RWLIST_RDLOCK(&pvt_list);
+	ast_cli(fd, "Channel List:\n");
+	AST_RWLIST_TRAVERSE(&pvt_list, p, next) {
 		if (misdn_debug[0] > 2)
-			ast_cli(fd, "Bc:%p Ast:%p\n", ch->bc, ch->ast);
-		if (ch->bc) {
-			print_bc_info(fd, ch, ch->bc);
+			ast_cli(fd, "Bc:%p Ast:%p\n", p->bc, p->ast);
+		if (p->bc) {
+			print_bc_info(fd, p, p->bc);
 		} else {
-			if (statemachine_get_state(ch->sm) == MISDN_HOLDED)
+			if (statemachine_get_state(p->sm) == MISDN_HOLDED)
 				chan_misdn_log(0, 0, "IT'S A HOLDED BC:\n --> l3_id: %x\n --> dad:%s oad:%s\n --> hold_port: %d\n --> hold_channel: %d\n",
-							   ch->l3id, ch->ast->exten, AST_CID_P(ch->ast), ch->hold_info.port, ch->hold_info.channel);
+							   p->l3id, p->ast->exten, AST_CID_P(p->ast), p->hold_info.port, p->hold_info.channel);
 			else
-				ast_cli(fd,"* Channel in unknown STATE !!! Exten:%s, Callerid:%s\n", ch->ast->exten, AST_CID_P(ch->ast));
-		}
-	}
-	AST_RWLIST_UNLOCK(&ch_list);
+				ast_cli(fd,"* Channel in unknown STATE !!! Exten:%s, Callerid:%s\n", p->ast->exten, AST_CID_P(p->ast));
+		}
+	}
+	AST_RWLIST_UNLOCK(&pvt_list);
 
 	return 0;
 }
 
 static int misdn_show_cl (int fd, int argc, char *argv[])
 {
-	struct misdn_ch *ch;
+	struct misdn_pvt *p;
 
 	if (argc != 4)
 		return RESULT_SHOWUSAGE;
 
-	AST_RWLIST_RDLOCK(&ch_list);
-	ast_cli(fd, "Chan List:\n");
-	AST_RWLIST_TRAVERSE(&ch_list, ch, next) {
-		if (ch->bc && ch->ast && !strcasecmp(ch->ast->name, argv[3])) {
-			print_bc_info(fd, ch, ch->bc);
+	AST_RWLIST_RDLOCK(&pvt_list);
+	ast_cli(fd, "Channel List:\n");
+	AST_RWLIST_TRAVERSE(&pvt_list, p, next) {
+		if (p->bc && p->ast && !strcasecmp(p->ast->name, argv[3])) {
+			print_bc_info(fd, p, p->bc);
 			break; 
 		}
 	}
-	AST_RWLIST_UNLOCK(&ch_list);
+	AST_RWLIST_UNLOCK(&pvt_list);
 
 	return 0;
 }
@@ -2386,26 +2384,26 @@
 };
 
 /* Channel configuration */
-static int config_ch_pres_screen (struct misdn_ch *ch)
+static int config_ch_pres_screen (struct misdn_pvt *p)
 {
 	struct ast_channel *ast;
 	struct misdn_bchannel *bc;
 	int	pres = 0,
 		screen = 0;
 
-	if (!ch) {
-		ast_log(LOG_WARNING, "Cannot configure without chanlist\n");
+	if (!p) {
+		ast_log(LOG_WARNING, "Cannot configure without misdn_pvt\n");
 		return -1;
 	}
 
-	ast = ch->ast;
-	bc = ch->bc;
+	ast = p->ast;
+	bc = p->bc;
 	if (!ast || !bc) {
 		ast_log(LOG_WARNING, "Cannot configure without ast || bc\n");
 		return -1;
 	}
 
-	if (ch->orginator == ORG_AST) {
+	if (p->orginator == ORG_AST) {
 		/*misdn_call*/
 		chan_misdn_log(5, bc->port, "config_ch_pres_screen: Getting Config\n");
 		cm_get_int(misdn_cm, pres, PORT, MCFG_PRESENTATION, bc->port);
@@ -2477,15 +2475,15 @@
 			screen = AST_PRES_USER_NUMBER_UNSCREENED;
 			chan_misdn_log(2, bc->port, " --> SCREEN: Unscreened (%d)\n", bc->screen);
 		}
-		ch->ast->cid.cid_pres = pres + screen;
+		p->ast->cid.cid_pres = pres + screen;
 	}
 
 	return 0;
 }
 
-static int config_ch_hdlc (struct misdn_ch *ch)
-{
-	struct misdn_bchannel *bc = ch->bc;
+static int config_ch_hdlc (struct misdn_pvt *p)
+{
+	struct misdn_bchannel *bc = p->bc;
 	int hdlc;
 
 	if (cm_get_int(misdn_cm, hdlc, PORT, MCFG_HDLC, bc->port) || hdlc < 0)
@@ -2502,11 +2500,11 @@
 	return 0;
 }
 
-static void config_ch_jitterbuffer (struct misdn_ch *ch)
-{
-	struct misdn_bchannel *bc = ch->bc;
-	int len = ch->jb_len,
-		threshold = ch->jb_upper_threshold;
+static void config_ch_jitterbuffer (struct misdn_pvt *p)
+{
+	struct misdn_bchannel *bc = p->bc;
+	int len = p->jb_len,
+		threshold = p->jb_upper_threshold;
 
 	chan_misdn_log(5, bc->port, "config_ch_jitterbuffer: Called\n");
 
@@ -2520,13 +2518,13 @@
 		}
 		if (threshold > len)
 			chan_misdn_log(0, bc->port, "config_ch_jitterbuffer: Jitterbuffer Threshold > Jitterbuffer setting to Jitterbuffer -1\n");
-		if (ch->jb) {
+		if (p->jb) {
 			chan_misdn_log(0, bc->port, "config_ch_jitterbuffer: We've got a Jitterbuffer Already on this port.\n");
-			misdn_jb_destroy(ch->jb);
-			ch->jb = NULL;
-		}
-		ch->jb = misdn_jb_init(len, threshold);
-		if (!ch->jb) 
+			misdn_jb_destroy(p->jb);
+			p->jb = NULL;
+		}
+		p->jb = misdn_jb_init(len, threshold);
+		if (!p->jb) 
 			bc->nojitter = 1;
 	}
 }
@@ -2544,7 +2542,7 @@
 	return 0;
 }
 
-static int config_ch (struct misdn_ch *ch, int orig)
+static int config_ch (struct misdn_pvt *p, int orig)
 {
 	struct ast_channel *ast;
 	struct misdn_bchannel *bc;
@@ -2553,13 +2551,13 @@
 	ast_group_t pg,
 				cg;
 
-	if (!ch) {
-		ast_log(LOG_WARNING, "Cannot configure without chanlist\n");
+	if (!p) {
+		ast_log(LOG_WARNING, "Cannot configure without misdn_pvt\n");
 		return -1;
 	}
 
-	ast = ch->ast;
-	bc = ch->bc;
+	ast = p->ast;
+	bc = p->bc;
 	if (!ast || !bc) {
 		ast_log(LOG_WARNING, "Cannot configure without ast || bc\n");
 		return -1;
@@ -2581,16 +2579,16 @@
 	bc->AOCDtype = Fac_None;
 	config_bc_echocancel(bc);
 
-	cm_get_int(misdn_cm, ch->incoming_early_audio, PORT, MCFG_INCOMING_EARLY_AUDIO, bc->port);
-	cm_get_int(misdn_cm, ch->jb_len, PORT, MCFG_JITTERBUFFER, bc->port);
-	cm_get_int(misdn_cm, ch->jb_upper_threshold, PORT, MCFG_JITTERBUFFER_UPPER_THRES, bc->port);
-	cm_get_int(misdn_cm, ch->nttimeout, PORT, MCFG_NTTIMEOUT, bc->port);
-	cm_get(misdn_cm, ch->allowed_bearers, sizeof(ch->allowed_bearers), PORT, MCFG_ALLOWED_BEARERS, bc->port);
-	cm_get(misdn_cm, ch->context, sizeof(ch->context), PORT, MCFG_CONTEXT, bc->port);
-	ast_copy_string(ast->context, ch->context, sizeof(ast->context));	
-	ch->overlap_dial_task = -1;
-	config_ch_hdlc(ch);
-	config_ch_jitterbuffer(ch);
+	cm_get_int(misdn_cm, p->incoming_early_audio, PORT, MCFG_INCOMING_EARLY_AUDIO, bc->port);
+	cm_get_int(misdn_cm, p->jb_len, PORT, MCFG_JITTERBUFFER, bc->port);
+	cm_get_int(misdn_cm, p->jb_upper_threshold, PORT, MCFG_JITTERBUFFER_UPPER_THRES, bc->port);
+	cm_get_int(misdn_cm, p->nttimeout, PORT, MCFG_NTTIMEOUT, bc->port);
+	cm_get(misdn_cm, p->allowed_bearers, sizeof(p->allowed_bearers), PORT, MCFG_ALLOWED_BEARERS, bc->port);
+	cm_get(misdn_cm, p->context, sizeof(p->context), PORT, MCFG_CONTEXT, bc->port);
+	ast_copy_string(ast->context, p->context, sizeof(ast->context));	
+	p->overlap_dial_task = -1;
+	config_ch_hdlc(p);
+	config_ch_jitterbuffer(p);
 
 	cm_get(misdn_cm, buf, sizeof(buf), PORT, MCFG_PICKUPGROUP, bc->port);
 	sscanf(buf, "%lld", &pg);
@@ -2606,9 +2604,9 @@
 	if (orig == ORG_AST) {
 		if (strstr(faxdetect, "outgoing") || strstr(faxdetect, "both")) {
 			if (strstr(faxdetect, "nojump"))
-				ch->faxdetect = 2;
+				p->faxdetect = 2;
 			else
-				ch->faxdetect = 1;
+				p->faxdetect = 1;
 		}
 

[... 1793 lines stripped ...]


More information about the asterisk-commits mailing list