[asterisk-commits] rmudgett: branch group/issue14292 r197687 - /team/group/issue14292/channels/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu May 28 12:00:48 CDT 2009
Author: rmudgett
Date: Thu May 28 12:00:03 2009
New Revision: 197687
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=197687
Log:
* Collected non-call associated libpri subcommand processing into
dahdi_pri_handle_noncall_subcmds().
* Cleaned up ccbsnr_remote_user_free().
Modified:
team/group/issue14292/channels/chan_dahdi.c
Modified: team/group/issue14292/channels/chan_dahdi.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/issue14292/channels/chan_dahdi.c?view=diff&rev=197687&r1=197686&r2=197687
==============================================================================
--- team/group/issue14292/channels/chan_dahdi.c (original)
+++ team/group/issue14292/channels/chan_dahdi.c Thu May 28 12:00:03 2009
@@ -2045,13 +2045,11 @@
{
struct ast_channel *ast;
struct ccbsnr_link *ccbsnr;
- int state = AST_STATE_DOWN;
struct dahdi_pvt *dummy;
ast_verb(3, "ccbsnr_remote_user_free: handle %x\n", handle);
ast_mutex_lock(&ccbsnr_lock);
-
ccbsnr = ccbsnr_list;
while (ccbsnr) {
if (ccbsnr->handle == handle) {
@@ -2061,56 +2059,45 @@
}
ast_mutex_unlock(&ccbsnr_lock);
- if (!(ccbsnr)) {
+ if (!ccbsnr) {
ast_log(LOG_ERROR, "DAHDI: CCBS/CCBR reference not found!\n");
return;
}
- ast = ast_channel_alloc(0, state, 0, 0, "", "", "", 0, 0);
- if (!ast) {
- ast_log(LOG_ERROR, "Unable to allocate channel!\n");
- return;
- }
-
- ast->tech = &dahdi_tech;
- dummy = ast_calloc(1,sizeof(*dummy));
+/* XXX Not sure that a dummy pvt structure is needed since is was not needed for mISDN */
+ dummy = ast_calloc(1, sizeof(*dummy));
if (!dummy) {
ast_log(LOG_ERROR, "Unable to allocate dummy:struct dahdi_pvt!\n");
return;
}
ast_mutex_init(&dummy->lock);
dummy->dummychannel = 1;
+
+ ast = ast_channel_alloc(0, AST_STATE_DOWN, ccbsnr->callernum, ccbsnr->callername,
+ NULL, ccbsnr->callingnum, ccbsnr->context, 0, "CCBSNR/%x", handle);
+ if (!ast) {
+ ast_free(dummy);
+ ast_log(LOG_ERROR, "Unable to allocate channel!\n");
+ return;
+ }
+
+ ast->tech = &dahdi_tech;
ast->tech_pvt = dummy;
- ast_string_field_build(ast, name, "CCBSNR/%x", ccbsnr->handle);
-
- ast_verb(3, "ccbsnr_remote_user_free: ast=%p name=%s ast->_softhangup=%x ast->tech%p\n",
- ast, ast->name, ast->_softhangup, ast->tech);
-
- ast->_softhangup = 0;
- memset(&ast->whentohangup, 0, sizeof(ast->whentohangup));
ast->priority = ccbsnr->priority;
-
- if (ast->cid.cid_num) {
- ast_free(ast->cid.cid_num);
- }
- ast->cid.cid_num = ast_strdup(ccbsnr->callernum);
-
if (ast->cid.cid_dnid) {
ast_free(ast->cid.cid_dnid);
}
- ast->cid.cid_name = ast_strdup(ccbsnr->callername);
-
- ast_copy_string(ast->context, ccbsnr->context, sizeof(ast->context));
- ast_copy_string(ast->exten, ccbsnr->callingnum, sizeof(ast->exten));
-
- ast_setstate(ast, state);
- ast_verb(3, "ccbsnr_remote_user_free: ast_pbx_start:ast %p cc-req(%d)\n",
- ast, ccbsnr->type);
-
+ ast->cid.cid_dnid = ast_strdup(ccbsnr->callingnum);
+
+ ast_verb(3, "ccbsnr_remote_user_free: ast_pbx_start:ast %p name=%s cc-req(%d)\n",
+ ast, ast->name, ccbsnr->type);
if (ast_pbx_start(ast)) {
int ccbs_span;
struct dahdi_pri *ccbs_pri;
+
+ ast_log(LOG_ERROR, "DAHDI: CCBS/CCNR: Unable to start pbx!\n");
+ ast_channel_release(ast);
pri_call_set_cc_operation(ccbsnr->call, PRI_CC_CANCEL);
@@ -2125,9 +2112,6 @@
pri_rel(ccbs_pri);
ccbsnr->call = NULL;
ccbsnr_del_link(ccbsnr->handle);
-
- ast_log(LOG_ERROR, "DAHDI: CCBS/CCNR: Unable to start pbx!\n");
-
return;
} else {
ast_verb(3,
@@ -14126,15 +14110,161 @@
ast_channel_queue_redirecting_update(owner, &redirecting);
}
break;
+ case PRI_SUBCMD_CC_RINGOUT_INV:
+ ast_verb(3, "cc-ringout INV on channel %d/%d, span %d\n",
+ pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset,
+ pri->span);
+ break;
default:
ast_log(LOG_WARNING,
- "Unknown subcommand %d in %s event on channel %d/%d on span %d.\n",
+ "Unknown subcommand(%d) in %s event on channel %d/%d on span %d.\n",
subcmd->cmd, pri_event2str(event_id), PRI_SPAN(channel),
PRI_CHANNEL(channel), pri->span);
break;
}
}
//ast_mutex_unlock(&pri->pvts[chanpos]->lock);
+}
+#endif /* defined(HAVE_PRI) */
+
+#if defined(HAVE_PRI)
+/*!
+ * \internal
+ * \brief Handle the non-call associated PRI subcommand events.
+ * \since 1.6.3
+ *
+ * \param pri DAHDI PRI control structure.
+ * \param cref Non-call call reference.
+ * \param event_id PRI event id
+ * \param channel PRI encoded span/channel
+ * \param subcmds Subcommands to process if any. (Could be NULL).
+ *
+ * \return Nothing
+ */
+static void dahdi_pri_handle_noncall_subcmds(struct dahdi_pri *pri, int cref, int event_id, int channel, const struct pri_subcommands *subcmds)
+{
+ int index;
+ unsigned int handle;
+ unsigned int state;
+ int no_path_reservation;
+ int retain_service;
+ struct ccbsnr_link *cclink;
+ struct ast_channel *peer;
+
+ if (!subcmds) {
+ return;
+ }
+ for (index = 0; index < subcmds->counter_subcmd; ++index) {
+ const struct pri_subcommand *subcmd = &subcmds->subcmd[index];
+
+ switch (subcmd->cmd) {
+ case PRI_SUBCMD_CC_EXECPOSIBLE_INV:
+ ast_verb(4,
+ "cc-execpossible INV cref %d channel %d/%d, span %d\n", cref,
+ PRI_SPAN(channel), PRI_CHANNEL(channel), pri->span);
+
+ handle = CCBS_HANDLE(PRI_SPAN(channel), cref);
+ state = 0;
+ ast_verb(4, "cc-execpossible: handle=%x\n", handle);
+ if (ccbsnr_get_link(handle, &state) != NULL) {
+ if (state == CC_INVOKED_A_RET) {
+ ast_verb(4, "DAHDI ccbsnr_remote_user_free: state '%d'\n",
+ state);
+ ccbsnr_remote_user_free(handle);
+ }
+ } else {
+ ast_verb(3,
+ "cc-execpossible: List-obj not found - handle=%x state=%d\n",
+ handle, state);
+ }
+ break;
+ case PRI_SUBCMD_CC_CCBSREQUEST_RR:
+ no_path_reservation = subcmd->cc_ccbs_rr.cc_request_res.no_path_reservation;
+ retain_service = subcmd->cc_ccbs_rr.cc_request_res.retain_service;
+
+ ast_verb(4,
+ "ccbs-request RR no-path-reservation '%d' retain-service '%d' on channel %d/%d on span %d\n",
+ no_path_reservation, retain_service,
+ PRI_SPAN(channel), PRI_CHANNEL(channel), pri->span);
+ handle = CCBS_HANDLE(PRI_SPAN(channel), cref);
+ cclink = ccbsnr_select_link(handle);
+ if (cclink) {
+ struct ast_channel *peer;
+
+ peer = cclink->peer;
+ cclink->peer = NULL;
+ ast_verb(4, "peer on CCBS-List-Obj (%p))\n", peer);
+
+ if (peer) {
+ ast_verb(4,
+ "fac-ev:PRI_CC_CCBSREQUEST:set per peer %p state ACTIVATED\n",
+ peer);
+ pbx_builtin_setvar_helper(peer, "CCBSNRREQSTATE", "ACTIVATED");
+ } else {
+ ast_verb(4,
+ "PRI_EVENT_ANSWER: No peer on CCBS-List-Obj found\n");
+ }
+ } else {
+ ast_verb(3,
+ "CCBS-List-Obj not found: channel(0x%x) span(%d) explicit(%d) channel(%d)\n",
+ channel, PRI_SPAN(channel), PRI_EXPLICIT(channel),
+ PRI_CHANNEL(channel));
+ }
+ break;
+ case PRI_SUBCMD_CC_CCNRREQUEST_RR:
+ no_path_reservation = subcmd->cc_ccnr_rr.cc_request_res.no_path_reservation;
+ retain_service = subcmd->cc_ccnr_rr.cc_request_res.retain_service;
+
+ ast_verb(3,
+ "ccnr-request RR no-path-reservation '%d' retain-service '%d' on channel %d/%d on span %d\n",
+ no_path_reservation, retain_service,
+ PRI_SPAN(channel), PRI_CHANNEL(channel), pri->span);
+ handle = CCBS_HANDLE(PRI_SPAN(channel), cref);
+ cclink = ccbsnr_select_link(handle);
+ if (cclink) {
+ peer = cclink->peer;
+ cclink->peer = NULL;
+ ast_verb(4, "peer on CCBS-List-Obj (%p))\n", peer);
+
+ if (peer) {
+ ast_verb(4,
+ "fac-ev:PRI_CC_CCBSREQUEST:set per peer %p state ACTIVATED\n",
+ peer);
+ pbx_builtin_setvar_helper(peer, "CCBSNRREQSTATE", "ACTIVATED");
+ } else {
+ ast_verb(3, "PRI_EVENT_ANSWER: No peer on CCBS-List-Obj found\n");
+ }
+ } else {
+ ast_verb(3,
+ "CCBS-List-Obj not found: channel(0x%x) span(%d) explicit(%d) channel(%d)\n",
+ channel, PRI_SPAN(channel), PRI_EXPLICIT(channel),
+ PRI_CHANNEL(channel));
+ }
+ break;
+ case PRI_SUBCMD_CC_ERROR:
+ ast_verb(4,
+ "cc-error RR value '%d' on channel %d/%d on span %d\n",
+ subcmd->cc_error.error_value, PRI_SPAN(channel), PRI_CHANNEL(channel),
+ pri->span);
+ break;
+ case PRI_SUBCMD_CC_CANCEL_INV:
+ ast_verb(4,
+ "cc-cancel INV numberA '%s' numberB '%s' on channel %d/%d on span %d\n",
+ subcmd->cc_cancel_inv.cc_optional_arg.number_A,
+ subcmd->cc_cancel_inv.cc_optional_arg.number_B,
+ PRI_SPAN(channel), PRI_CHANNEL(channel), pri->span);
+ break;
+ default:
+ ast_log(LOG_WARNING,
+ "Unknown non-call subcommand(%d) in %s event on channel %d/%d on span %d.\n",
+ subcmd->cmd, pri_event2str(event_id), PRI_SPAN(channel),
+ PRI_CHANNEL(channel), pri->span);
+ break;
+ }
+ }
+
+ /* NOTE: PRI_CHANNEL(channel) is always going to be zero in this function. */
+ /*! \todo BUGBUG dahdi_pri_handle_noncall_subcmds() not written */
}
#endif /* defined(HAVE_PRI) */
@@ -15064,47 +15194,8 @@
PRI_EXPLICIT(e->facility.channel), PRI_CHANNEL(e->facility.channel));
if (PRI_CHANNEL(e->facility.channel) == 0) {
/* No channel Connection */
- unsigned int handle;
- int i;
-
- for (i = 0; i < e->facility.subcmds->counter_subcmd; i++) {
- struct pri_subcommand *subcmd = &e->facility.subcmds->subcmd[i];
-
- switch (subcmd->cmd) {
- case PRI_SUBCMD_CC_EXECPOSIBLE_INV:
- {
- int cr = e->facility.cref;
- unsigned int state;
-
- ast_verb(4,
- "Facility cc-execposible INV cr %d channel %d/%d, span %d\n",
- cr, PRI_SPAN(e->facility.channel), PRI_CHANNEL(e->facility.channel), pri->span);
-
- handle = CCBS_HANDLE(PRI_SPAN(e->facility.channel), cr);
- state = 0;
- ast_verb(4,
- "Facility cc-execposible: handle=%x\n", handle);
- if (ccbsnr_get_link(handle, &state) != NULL) {
- if (state == CC_INVOKED_A_RET) {
- ast_verb(4,
- "DAHDI ccbsnr_remote_user_free: state '%d'\n",
- state);
- ccbsnr_remote_user_free(handle);
- }
- } else {
- ast_verb(3,
- "Facility cc-execposible: List-obj not found - handle=%x state=%d\n",
- handle, state);
- }
- break;
- }
- default:
- ast_log(LOG_WARNING,
- "Illegal subcommand %d in facility request on channel %d/%d span %d\n",
- subcmd->cmd, PRI_SPAN(e->facility.channel), PRI_CHANNEL(e->facility.channel), pri->span);
- break;
- }
- }
+ dahdi_pri_handle_noncall_subcmds(pri, e->facility.cref, e->e,
+ e->facility.channel, e->facility.subcmds);
break;
}
@@ -15129,95 +15220,11 @@
ast_verb(4,
"PRI_EVENT_ANSWER e->answer.channel(0x%x) span(%d) explicit(%d) channel(%d)\n",
e->answer.channel, PRI_SPAN(e->answer.channel),
- PRI_EXPLICIT(e->answer.channel), e->answer.channel);
- if (e->answer.channel == 0) {
+ PRI_EXPLICIT(e->answer.channel), PRI_CHANNEL(e->answer.channel));
+ if (PRI_CHANNEL(e->answer.channel) == 0) {
/* No channel Connection */
- int i;
-
- for (i = 0; i < e->answer.subcmds->counter_subcmd; i++) {
- struct ccbsnr_link *cclink;
- unsigned int handle;
- int cr = e->answer.cref;
- struct pri_subcommand *subcmd = &e->answer.subcmds->subcmd[i];
-
- switch (subcmd->cmd) {
- case PRI_SUBCMD_CC_CCBSREQUEST_RR:
- {
- int no_path_reservation = subcmd->cc_ccbs_rr.cc_request_res.no_path_reservation;
- int retain_service = subcmd->cc_ccbs_rr.cc_request_res.retain_service;
-
- ast_verb(4,
- "Answer ccbs-request RR no-path-reservation '%d' retain-service '%d' on channel %d/%d on span %d\n",
- no_path_reservation, retain_service,
- PRI_SPAN(e->answer.channel), PRI_CHANNEL(e->answer.channel), pri->span);
- handle = CCBS_HANDLE(PRI_SPAN(e->answer.channel),cr);
- cclink = ccbsnr_select_link(handle);
- if (cclink) {
- struct ast_channel *peer;
-
- peer = cclink->peer;
- cclink->peer = NULL;
- ast_verb(4,
- "PRI_EVENT_ANSWER: peer on CCBS-List-Obj (%p))\n",
- peer);
-
- if (peer) {
- ast_verb(4,
- "fac-ev:PRI_CC_CCBSREQUEST:set per peer %p state ACTIVATED\n",
- peer);
- pbx_builtin_setvar_helper(peer, "CCBSNRREQSTATE", "ACTIVATED");
- } else {
- ast_verb(4,
- "PRI_EVENT_ANSWER: No peer on CCBS-List-Obj found\n");
- }
- } else {
- ast_verb(3,
- "PRI_EVENT_ANSWER: CCBS-List-Obj not found: e->answer.channel(0x%x) span(%d) explicit(%d) channel(%d)\n",
- e->answer.channel, PRI_SPAN(e->answer.channel), PRI_EXPLICIT(e->answer.channel), e->answer.channel);
- }
- break;
- }
-
- case PRI_SUBCMD_CC_CCNRREQUEST_RR:
- {
- int no_path_reservation = subcmd->cc_ccnr_rr.cc_request_res.no_path_reservation;
- int retain_service = subcmd->cc_ccnr_rr.cc_request_res.retain_service;
-
- ast_verb(3,
- "Answer ccnr-request RR no-path-reservation '%d' retain-service '%d' on channel %d/%d on span %d\n",
- no_path_reservation, retain_service,
- PRI_SPAN(e->answer.channel), PRI_CHANNEL(e->answer.channel), pri->span);
- handle = CCBS_HANDLE(PRI_SPAN(e->answer.channel),cr);
- cclink = ccbsnr_select_link(handle);
- if (cclink) {
- struct ast_channel *peer;
- peer = cclink->peer;
- cclink->peer = NULL;
- ast_verb(4,
- "PRI_EVENT_ANSWER: peer on CCBS-List-Obj (%p))\n", peer);
-
- if (peer) {
- ast_verb(4,
- "fac-ev:PRI_CC_CCBSREQUEST:set per peer %p state ACTIVATED\n",
- peer);
- pbx_builtin_setvar_helper(peer, "CCBSNRREQSTATE", "ACTIVATED");
- } else {
- ast_verb(3, "PRI_EVENT_ANSWER: No peer on CCBS-List-Obj found\n");
- }
- } else {
- ast_verb(3,
- "PRI_EVENT_ANSWER: CCBS-List-Obj not found: e->answer.channel(0x%x) span(%d) explicit(%d) channel(%d)\n",
- e->answer.channel, PRI_SPAN(e->answer.channel), PRI_EXPLICIT(e->answer.channel), e->answer.channel);
- }
- break;
- }
-
- default:
- ast_log(LOG_WARNING, "Illegal subcommand %d in answer on channel %d/%d span %d\n",
- subcmd->cmd, PRI_SPAN(e->answer.channel), PRI_CHANNEL(e->answer.channel), pri->span);
- break;
- }
- }
+ dahdi_pri_handle_noncall_subcmds(pri, e->answer.cref, e->e,
+ e->answer.channel, e->answer.subcmds);
break;
}
@@ -15304,41 +15311,18 @@
pri->span, e->hangup.cause);
if (PRI_CHANNEL(e->hangup.channel) == 0) {
/* No channel Connection */
- int errorvalue = 0;
struct ccbsnr_link *cclink;
unsigned int handle;
int cr;
unsigned int state;
- int i;
-
- for (i = 0; i < e->hangup.subcmds->counter_subcmd; i++) {
- struct pri_subcommand *subcmd = &e->hangup.subcmds->subcmd[i];
-
- switch (subcmd->cmd) {
- case PRI_SUBCMD_CC_ERROR:
- errorvalue = subcmd->cc_error.error_value;
- ast_verb(4,
- "Hangup cc-error RR value '%d' on channel %d/%d on span %d\n",
- errorvalue, PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span);
- break;
- case PRI_SUBCMD_CC_CANCEL_INV:
- ast_verb(4,
- "Hangup cc-cancel INV numberA '%s' numberB '%s' on channel %d/%d on span %d\n",
- subcmd->cc_cancel_inv.cc_optional_arg.number_A,
- subcmd->cc_cancel_inv.cc_optional_arg.number_B,
- PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span);
- break;
- default:
- ast_log(LOG_WARNING, "Illegal subcommand %d in hangup on channel %d/%d span %d\n",
- subcmd->cmd, PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span);
- break;
- }
- }
+
+ dahdi_pri_handle_noncall_subcmds(pri, e->hangup.cref, e->e,
+ e->hangup.channel, e->hangup.subcmds);
cr = e->hangup.cref;
state = 0;
- handle = CCBS_HANDLE(PRI_SPAN(e->hangup.channel),cr);
+ handle = CCBS_HANDLE(PRI_SPAN(e->hangup.channel), cr);
cclink = ccbsnr_get_link(handle, &state);
if (cclink) {
switch (state) {
@@ -15346,8 +15330,11 @@
case CC_WAIT_USER_A_ANSWER_N:
case CC_INVOKED_A_RET:
ast_verb(4,
- "PRI_EVENT_HANGUP: CCBS-List-Obj 0x%p: handle %x e->hangup.channel(0x%x) span(%d) explicit(%d) channel(%d) error(%d) peer=%p\n",
- cclink, handle, e->hangup.channel, PRI_SPAN(e->hangup.channel), PRI_EXPLICIT(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), errorvalue, cclink->peer);
+ "PRI_EVENT_HANGUP: CCBS-List-Obj 0x%p: handle %x e->hangup.channel(0x%x) span(%d) explicit(%d) channel(%d) peer=%p\n",
+ cclink, handle, e->hangup.channel,
+ PRI_SPAN(e->hangup.channel),
+ PRI_EXPLICIT(e->hangup.channel),
+ PRI_CHANNEL(e->hangup.channel), cclink->peer);
pri_hangup(pri->pri, cclink->call, e->hangup.cause);
cclink->call = NULL;
@@ -15359,9 +15346,12 @@
}
} else {
ast_verb(4, "PRI_EVENT_HANGUP: CCBS-List-Obj not found: e->hangup.channel(0x%x) span(%d) explicit(%d) channel(%d)\n",
- e->hangup.channel, PRI_SPAN(e->hangup.channel), PRI_EXPLICIT(e->hangup.channel), PRI_CHANNEL(e->hangup.channel));
+ e->hangup.channel, PRI_SPAN(e->hangup.channel),
+ PRI_EXPLICIT(e->hangup.channel),
+ PRI_CHANNEL(e->hangup.channel));
ast_verb(3, "Hangup on bad channel %d/%d on span %d\n",
- PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span);
+ PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel),
+ pri->span);
}
break;
}
@@ -15373,8 +15363,6 @@
} else {
chanpos = pri_fixup_principle(pri, chanpos, e->hangup.call);
if (chanpos > -1) {
- int i;
-
ast_mutex_lock(&pri->pvts[chanpos]->lock);
dahdi_pri_handle_subcmds(pri, chanpos, e->e, e->hangup.channel,
e->hangup.subcmds);
@@ -15431,21 +15419,6 @@
ast_mutex_lock(&pri->pvts[chanpos]->lock);
}
#endif
- for (i = 0; i < e->hangup.subcmds->counter_subcmd; i++) {
- struct pri_subcommand *subcmd = &e->hangup.subcmds->subcmd[i];
-
- switch (subcmd->cmd) {
- case PRI_SUBCMD_CC_RINGOUT_INV:
- ast_verb(3, "Facility cc-suspend INV on channel %d/%d, span %d\n",
- pri->pvts[chanpos]->logicalspan, pri->pvts[chanpos]->prioffset, pri->span);
- break;
-
- default:
- ast_log(LOG_WARNING, "Illegal subcommand %d in hangup on channel %d/%d not in use on span %d\n",
- subcmd->cmd, PRI_SPAN(e->hangup.channel), PRI_CHANNEL(e->hangup.channel), pri->span);
- break;
- }
- }
ast_mutex_unlock(&pri->pvts[chanpos]->lock);
} else {
More information about the asterisk-commits
mailing list