[asterisk-commits] rmudgett: branch group/issue14068 r210390 - in /team/group/issue14068: ./ cha...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Aug 4 12:53:27 CDT 2009
Author: rmudgett
Date: Tue Aug 4 12:53:25 2009
New Revision: 210390
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=210390
Log:
Merged revisions 210387 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
........
r210387 | rmudgett | 2009-08-04 12:46:03 -0500 (Tue, 04 Aug 2009) | 1 line
Fix CALLERID() values for sig_pri on incoming calls.
........
Modified:
team/group/issue14068/ (props changed)
team/group/issue14068/channels/chan_dahdi.c
team/group/issue14068/channels/sig_pri.c
team/group/issue14068/channels/sig_pri.h
Propchange: team/group/issue14068/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Aug 4 12:53:25 2009
@@ -1,1 +1,1 @@
-/trunk:1-210365
+/trunk:1-210389
Modified: team/group/issue14068/channels/chan_dahdi.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/issue14068/channels/chan_dahdi.c?view=diff&rev=210390&r1=210389&r2=210390
==============================================================================
--- team/group/issue14068/channels/chan_dahdi.c (original)
+++ team/group/issue14068/channels/chan_dahdi.c Tue Aug 4 12:53:25 2009
@@ -2563,6 +2563,62 @@
return tone_zone_play_tone(p->subs[SUB_REAL].dfd, sig_pri_tone_to_dahditone(tone));
}
+/*!
+ * \internal
+ * \brief Set the caller id information.
+ * \since 1.6.3
+ *
+ * \param pvt DAHDI private structure
+ * \param caller Caller-id information to set.
+ *
+ * \return Nothing
+ */
+static void my_pri_set_callerid(void *pvt, const struct ast_party_caller *caller)
+{
+ struct dahdi_pvt *p = pvt;
+
+ ast_copy_string(p->cid_num, S_OR(caller->id.number, ""), sizeof(p->cid_num));
+ ast_copy_string(p->cid_name, S_OR(caller->id.name, ""), sizeof(p->cid_name));
+ p->cid_ton = caller->id.number_type;
+ p->callingpres = caller->id.number_presentation;
+ ast_copy_string(p->cid_ani, S_OR(caller->ani, ""), sizeof(p->cid_ani));
+ p->cid_ani2 = caller->ani2;
+}
+
+/*!
+ * \internal
+ * \brief Set the Dialed Number Identifier.
+ * \since 1.6.3
+ *
+ * \param pvt DAHDI private structure
+ * \param dnid Dialed Number Identifier string.
+ *
+ * \return Nothing
+ */
+static void my_pri_set_dnid(void *pvt, const char *dnid)
+{
+ struct dahdi_pvt *p = pvt;
+
+ ast_copy_string(p->dnid, dnid, sizeof(p->dnid));
+}
+
+/*!
+ * \internal
+ * \brief Set the Redirecting Directory Number Information Service (RDNIS).
+ * \since 1.6.3
+ *
+ * \param pvt DAHDI private structure
+ * \param rdnis Redirecting Directory Number Information Service (RDNIS) string.
+ *
+ * \return Nothing
+ */
+static void my_pri_set_rdnis(void *pvt, const char *rdnis)
+{
+ struct dahdi_pvt *p = pvt;
+
+ ast_copy_string(p->rdnis, rdnis, sizeof(p->rdnis));
+}
+
static struct sig_pri_callback dahdi_pri_callbacks =
{
.handle_dchan_exception = my_handle_dchan_exception,
@@ -2573,6 +2629,9 @@
.new_ast_channel = my_new_pri_ast_channel,
.fixup_chans = my_pri_fixup_chans,
.set_dialing = my_set_dialing,
+ .set_callerid = my_pri_set_callerid,
+ .set_dnid = my_pri_set_dnid,
+ .set_rdnis = my_pri_set_rdnis,
};
#endif /* defined(HAVE_PRI) */
Modified: team/group/issue14068/channels/sig_pri.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/issue14068/channels/sig_pri.c?view=diff&rev=210390&r1=210389&r2=210390
==============================================================================
--- team/group/issue14068/channels/sig_pri.c (original)
+++ team/group/issue14068/channels/sig_pri.c Tue Aug 4 12:53:25 2009
@@ -97,7 +97,66 @@
static void sig_pri_set_dialing(struct sig_pri_chan *p, int flag)
{
if (p->calls->set_dialing)
- p->calls->set_dialing(p, flag);
+ p->calls->set_dialing(p->chan_pvt, flag);
+}
+
+/*!
+ * \internal
+ * \brief Set the caller id information in the parent module.
+ * \since 1.6.3
+ *
+ * \param p sig_pri channel structure.
+ *
+ * \return Nothing
+ */
+static void sig_pri_set_caller_id(struct sig_pri_chan *p)
+{
+ struct ast_party_caller caller;
+
+ if (p->calls->set_callerid) {
+ ast_party_caller_init(&caller);
+ caller.id.number = p->cid_num;
+ caller.id.name = p->cid_name;
+ caller.id.number_type = p->cid_ton;
+ caller.id.number_presentation = p->callingpres;
+ caller.ani = p->cid_ani;
+ caller.ani2 = p->cid_ani2;
+ p->calls->set_callerid(p->chan_pvt, &caller);
+ }
+}
+
+/*!
+ * \internal
+ * \brief Set the Dialed Number Identifier.
+ * \since 1.6.3
+ *
+ * \param p sig_pri channel structure.
+ * \param dnid Dialed Number Identifier string.
+ *
+ * \return Nothing
+ */
+static void sig_pri_set_dnid(struct sig_pri_chan *p, const char *dnid)
+{
+ if (p->calls->set_dnid) {
+ p->calls->set_dnid(p->chan_pvt, dnid);
+ }
+}
+
+/*!
+ * \internal
+ * \brief Set the Redirecting Directory Number Information Service (RDNIS).
+ * \since 1.6.3
+ *
+ * \param p sig_pri channel structure.
+ * \param rdnis Redirecting Directory Number Information Service (RDNIS) string.
+ *
+ * \return Nothing
+ */
+static void sig_pri_set_rdnis(struct sig_pri_chan *p, const char *rdnis)
+{
+ if (p->calls->set_rdnis) {
+ p->calls->set_rdnis(p->chan_pvt, rdnis);
+ }
}
static void sig_pri_unlock_private(struct sig_pri_chan *p)
@@ -943,6 +1002,10 @@
if (pri_connected->id.name.valid) {
ast_connected.id.name = (char *) pri_connected->id.name.str;
+ /* Save name for Caller-ID update */
+ ast_copy_string(pri->pvts[chanpos]->cid_name,
+ pri_connected->id.name.str,
+ sizeof(pri->pvts[chanpos]->cid_name));
caller_id_update = 1;
}
if (pri_connected->id.number.valid) {
@@ -952,6 +1015,10 @@
ast_connected.id.number = connected_number;
ast_connected.id.number_type = pri_connected->id.number.plan;
+ /* Save number for Caller-ID update */
+ ast_copy_string(pri->pvts[chanpos]->cid_num, connected_number,
+ sizeof(pri->pvts[chanpos]->cid_num));
+ pri->pvts[chanpos]->cid_ton = pri_connected->id.number.plan;
caller_id_update = 1;
} else {
ast_connected.id.number = "";
@@ -964,6 +1031,9 @@
ast_connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
if (caller_id_update) {
+ pri->pvts[chanpos]->callingpres =
+ ast_connected.id.number_presentation;
+ sig_pri_set_caller_id(pri->pvts[chanpos]);
ast_set_callerid(owner, S_OR(ast_connected.id.number, NULL),
S_OR(ast_connected.id.name, NULL),
S_OR(ast_connected.id.number, NULL));
@@ -1066,8 +1136,8 @@
pthread_t threadid;
pthread_attr_t attr;
char ani2str[6];
- char plancallingnum[256];
- char plancallingani[256];
+ char plancallingnum[AST_MAX_EXTENSION];
+ char plancallingani[AST_MAX_EXTENSION];
char calledtonstr[10];
struct timeval lastidle = { 0, 0 };
pthread_t p;
@@ -1534,7 +1604,15 @@
if (chanpos > -1) {
sig_pri_lock_private(pri->pvts[chanpos]);
pri->pvts[chanpos]->call = e->ring.call;
+
+ /* Use plancallingnum as a scratch buffer since it is initialized next. */
+ apply_plan_to_number(plancallingnum, sizeof(plancallingnum), pri,
+ e->ring.redirectingnum, e->ring.callingplanrdnis);
+ sig_pri_set_rdnis(pri->pvts[chanpos], plancallingnum);
+
+ /* Setup caller-id info */
apply_plan_to_number(plancallingnum, sizeof(plancallingnum), pri, e->ring.callingnum, e->ring.callingplan);
+ pri->pvts[chanpos]->cid_ani2 = 0;
if (pri->pvts[chanpos]->use_callerid) {
ast_shrink_phone_number(plancallingnum);
ast_copy_string(pri->pvts[chanpos]->cid_num, plancallingnum, sizeof(pri->pvts[chanpos]->cid_num));
@@ -1549,14 +1627,22 @@
#endif
ast_copy_string(pri->pvts[chanpos]->cid_name, e->ring.callingname, sizeof(pri->pvts[chanpos]->cid_name));
pri->pvts[chanpos]->cid_ton = e->ring.callingplan; /* this is the callingplan (TON/NPI), e->ring.callingplan>>4 would be the TON */
+ pri->pvts[chanpos]->callingpres = e->ring.callingpres;
+ if (e->ring.ani2 >= 0) {
+ pri->pvts[chanpos]->cid_ani2 = e->ring.ani2;
+ }
} else {
pri->pvts[chanpos]->cid_num[0] = '\0';
pri->pvts[chanpos]->cid_ani[0] = '\0';
pri->pvts[chanpos]->cid_name[0] = '\0';
pri->pvts[chanpos]->cid_ton = 0;
+ pri->pvts[chanpos]->callingpres = 0;
}
- apply_plan_to_number(pri->pvts[chanpos]->rdnis, sizeof(pri->pvts[chanpos]->rdnis), pri,
- e->ring.redirectingnum, e->ring.callingplanrdnis);
+ sig_pri_set_caller_id(pri->pvts[chanpos]);
+
+ /* Set DNID on all incoming calls -- even immediate */
+ sig_pri_set_dnid(pri->pvts[chanpos], e->ring.callednum);
+
/* If immediate=yes go to s|1 */
if (pri->pvts[chanpos]->immediate) {
ast_verb(3, "Going to extension s|1 because of immediate=yes\n");
@@ -1573,14 +1659,13 @@
pri->pvts[chanpos]->exten[0] = 's';
pri->pvts[chanpos]->exten[1] = '\0';
}
- /* Set DNID on all incoming calls -- even immediate */
- ast_copy_string(pri->pvts[chanpos]->dnid, e->ring.callednum, sizeof(pri->pvts[chanpos]->dnid));
/* No number yet, but received "sending complete"? */
if (e->ring.complete && (ast_strlen_zero(e->ring.callednum))) {
ast_verb(3, "Going to extension s|1 because of Complete received\n");
pri->pvts[chanpos]->exten[0] = 's';
pri->pvts[chanpos]->exten[1] = '\0';
}
+
/* Make sure extension exists (or in overlap dial mode, can exist) */
if (((pri->overlapdial & DAHDI_OVERLAPDIAL_INCOMING) && ast_canmatch_extension(NULL, pri->pvts[chanpos]->context, pri->pvts[chanpos]->exten, 1, pri->pvts[chanpos]->cid_num)) ||
ast_exists_extension(NULL, pri->pvts[chanpos]->context, pri->pvts[chanpos]->exten, 1, pri->pvts[chanpos]->cid_num)) {
@@ -1595,8 +1680,6 @@
else
pri_answer(pri->pri, e->ring.call, PVT_TO_CHANNEL(pri->pvts[chanpos]), 1);
}
- /* Get the use_callingpres state */
- pri->pvts[chanpos]->callingpres = e->ring.callingpres;
/* Start PBX */
if (!e->ring.complete
@@ -1616,7 +1699,6 @@
if (e->ring.ani2 >= 0) {
snprintf(ani2str, sizeof(ani2str), "%d", e->ring.ani2);
pbx_builtin_setvar_helper(c, "ANI2", ani2str);
- pri->pvts[chanpos]->cid_ani2 = e->ring.ani2;
}
#ifdef SUPPORT_USERUSER
@@ -1680,7 +1762,6 @@
if (e->ring.ani2 >= 0) {
snprintf(ani2str, sizeof(ani2str), "%d", e->ring.ani2);
pbx_builtin_setvar_helper(c, "ANI2", ani2str);
- pri->pvts[chanpos]->cid_ani2 = e->ring.ani2;
}
#ifdef SUPPORT_USERUSER
@@ -2229,7 +2310,6 @@
p->progress = 0;
p->alerting = 0;
p->setup_ack = 0;
- p->rdnis[0] = '\0';
p->exten[0] = '\0';
sig_pri_set_dialing(p, 0);
Modified: team/group/issue14068/channels/sig_pri.h
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/issue14068/channels/sig_pri.h?view=diff&rev=210390&r1=210389&r2=210390
==============================================================================
--- team/group/issue14068/channels/sig_pri.h (original)
+++ team/group/issue14068/channels/sig_pri.h Tue Aug 4 12:53:25 2009
@@ -71,6 +71,9 @@
/* Note: Called with PRI lock held */
void (* const handle_dchan_exception)(struct sig_pri_pri *pri, int index);
void (* const set_dialing)(void *pvt, int flag);
+ void (* const set_callerid)(void *pvt, const struct ast_party_caller *caller);
+ void (* const set_dnid)(void *pvt, const char *dnid);
+ void (* const set_rdnis)(void *pvt, const char *rdnis);
};
#define NUM_DCHANS 4 /*!< No more than 4 d-channels */
@@ -123,16 +126,14 @@
char mohinterpret[MAX_MUSICCLASS];
int stripmsd;
- /* Options to be checked by user */
+ /* Options to be checked by user */
int cid_ani2; /*!< Automatic Number Identification number (Alternate PRI caller ID number) */
+ int cid_ton; /*!< Type Of Number (TON) */
+ int callingpres; /*!< The value of calling presentation that we're going to use when placing a PRI call */
char cid_num[AST_MAX_EXTENSION];
- int cid_ton; /*!< Type Of Number (TON) */
char cid_name[AST_MAX_EXTENSION];
char cid_ani[AST_MAX_EXTENSION];
- char rdnis[AST_MAX_EXTENSION];
- char dnid[AST_MAX_EXTENSION];
char exten[AST_MAX_EXTENSION];
- int callingpres; /*!< The value of calling presentation that we're going to use when placing a PRI call */
/* Internal variables -- Don't touch */
/* Probably will need DS0 number, DS1 number, and a few other things */
@@ -159,7 +160,7 @@
int mastertrunkgroup; /*!< what trunk group is our master */
struct sig_pri_callback *calls;
- void *chan_pvt;
+ void *chan_pvt; /*!< Private structure of the user of this module. */
ast_mutex_t service_lock; /*!< Mutex for service messages */
#if defined(HAVE_PRI_REVERSE_CHARGE)
int reverse_charging_indication;
More information about the asterisk-commits
mailing list