aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorrmudgett <rmudgett@f38db490-d61c-443f-a65b-d21fe96a405b>2010-04-03 02:12:33 +0000
committerrmudgett <rmudgett@f38db490-d61c-443f-a65b-d21fe96a405b>2010-04-03 02:12:33 +0000
commitf42e29b281d0cd12ab8ec57afc89061c613e4d62 (patch)
treed5314391644adec2c19d0dc0b36644a20a12c759 /apps
parentfa32b379746e68f554e1b59db0911a2181bfcb75 (diff)
Consolidate ast_channel.cid.cid_rdnis into ast_channel.redirecting.from.number.
SWP-1229 ABE-2161 * Ensure chan_local.c:local_call() will not leak cid.cid_dnid when copying. git-svn-id: http://svn.digium.com/svn/asterisk/trunk@256104 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r--apps/app_amd.c3
-rw-r--r--apps/app_dial.c30
-rw-r--r--apps/app_dumpchan.c2
-rw-r--r--apps/app_queue.c28
4 files changed, 31 insertions, 32 deletions
diff --git a/apps/app_amd.c b/apps/app_amd.c
index 30f6da058..928afee0b 100644
--- a/apps/app_amd.c
+++ b/apps/app_amd.c
@@ -188,7 +188,8 @@ static void isAnsweringMachine(struct ast_channel *chan, const char *data)
AST_APP_ARG(argMaximumWordLength);
);
- ast_verb(3, "AMD: %s %s %s (Fmt: %s)\n", chan->name, chan->cid.cid_ani, chan->cid.cid_rdnis, ast_getformatname(chan->readformat));
+ ast_verb(3, "AMD: %s %s %s (Fmt: %s)\n", chan->name, chan->cid.cid_ani,
+ chan->redirecting.from.number, ast_getformatname(chan->readformat));
/* Lets parse the arguments. */
if (!ast_strlen_zero(parse)) {
diff --git a/apps/app_dial.c b/apps/app_dial.c
index d4b16a36b..8a58932a8 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -691,12 +691,11 @@ static void handle_cause(int cause, struct cause_args *num)
}
}
-/* free the buffer if allocated, and set the pointer to the second arg */
-#define S_REPLACE(s, new_val) \
- do { \
- if (s) \
- ast_free(s); \
- s = (new_val); \
+/*! \brief free the buffer if allocated, and set the pointer to the second arg */
+#define S_REPLACE(s, new_val) \
+ do { \
+ ast_free(s); \
+ s = (new_val); \
} while (0)
static int onedigit_goto(struct ast_channel *chan, const char *context, char exten, int pri)
@@ -773,8 +772,6 @@ static void do_forward(struct chanlist *o,
struct ast_channel *original = o->chan;
struct ast_channel *c = o->chan; /* the winner */
struct ast_channel *in = num->chan; /* the input channel */
- struct ast_party_redirecting *apr = &o->chan->redirecting;
- struct ast_party_connected_line *apc = &o->chan->connected;
char *stuff;
char *tech;
int cause;
@@ -825,12 +822,19 @@ static void do_forward(struct chanlist *o,
ast_rtp_instance_early_bridge_make_compatible(c, in);
}
- ast_channel_set_redirecting(c, apr);
+ ast_channel_set_redirecting(c, &original->redirecting);
ast_channel_lock(c);
while (ast_channel_trylock(in)) {
CHANNEL_DEADLOCK_AVOIDANCE(c);
}
- S_REPLACE(c->cid.cid_rdnis, ast_strdup(S_OR(original->cid.cid_rdnis, S_OR(in->macroexten, in->exten))));
+ if (ast_strlen_zero(c->redirecting.from.number)) {
+ /*
+ * The call was not previously redirected so it is
+ * now redirected from this number.
+ */
+ S_REPLACE(c->redirecting.from.number,
+ ast_strdup(S_OR(in->macroexten, in->exten)));
+ }
c->cid.cid_tns = in->cid.cid_tns;
@@ -842,10 +846,9 @@ static void do_forward(struct chanlist *o,
ast_party_caller_copy(&c->cid, &in->cid);
ast_string_field_set(c, accountcode, in->accountcode);
}
- ast_party_connected_line_copy(&c->connected, apc);
+ ast_party_connected_line_copy(&c->connected, &original->connected);
- S_REPLACE(in->cid.cid_rdnis, ast_strdup(c->cid.cid_rdnis));
- ast_channel_update_redirecting(in, apr);
+ ast_channel_update_redirecting(in, &c->redirecting);
ast_clear_flag64(peerflags, OPT_IGNORE_CONNECTEDLINE);
if (ast_test_flag64(peerflags, OPT_CANCEL_TIMEOUT)) {
@@ -1913,7 +1916,6 @@ static int dial_exec_full(struct ast_channel *chan, const char *data, struct ast
ast_connected_line_copy_from_caller(&tc->connected, &chan->cid);
}
- S_REPLACE(tc->cid.cid_rdnis, ast_strdup(chan->cid.cid_rdnis));
ast_party_redirecting_copy(&tc->redirecting, &chan->redirecting);
tc->cid.cid_tns = chan->cid.cid_tns;
diff --git a/apps/app_dumpchan.c b/apps/app_dumpchan.c
index a7b4fc001..d66661db6 100644
--- a/apps/app_dumpchan.c
+++ b/apps/app_dumpchan.c
@@ -119,7 +119,7 @@ static int serialize_showchan(struct ast_channel *c, char *buf, size_t size)
S_OR(c->cid.cid_num, "(N/A)"),
S_OR(c->cid.cid_name, "(N/A)"),
S_OR(c->cid.cid_dnid, "(N/A)"),
- S_OR(c->cid.cid_rdnis, "(N/A)"),
+ S_OR(c->redirecting.from.number, "(N/A)"),
c->parkinglot,
c->language,
ast_state2str(c->_state),
diff --git a/apps/app_queue.c b/apps/app_queue.c
index 3dac6a4ab..e689cb080 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -2835,9 +2835,6 @@ static int ring_entry(struct queue_ent *qe, struct callattempt *tmp, int *busies
tmp->update_connectedline = 0;
}
- if (tmp->chan->cid.cid_rdnis)
- ast_free(tmp->chan->cid.cid_rdnis);
- tmp->chan->cid.cid_rdnis = ast_strdup(qe->chan->cid.cid_rdnis);
ast_party_redirecting_copy(&tmp->chan->redirecting, &qe->chan->redirecting);
tmp->chan->cid.cid_tns = qe->chan->cid.cid_tns;
@@ -3275,8 +3272,6 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
winner = NULL;
continue;
} else if (!ast_strlen_zero(o->chan->call_forward)) {
- struct ast_party_redirecting *apr = &o->chan->redirecting;
- struct ast_party_connected_line *apc = &o->chan->connected;
struct ast_channel *original = o->chan;
char tmpchan[256];
char *stuff;
@@ -3312,22 +3307,23 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
ast_string_field_set(o->chan, accountcode, in->accountcode);
- ast_channel_set_redirecting(o->chan, apr);
-
- if (o->chan->cid.cid_rdnis)
- ast_free(o->chan->cid.cid_rdnis);
- o->chan->cid.cid_rdnis = ast_strdup(S_OR(original->cid.cid_rdnis,S_OR(in->macroexten, in->exten)));
+ ast_channel_set_redirecting(o->chan, &original->redirecting);
+ if (ast_strlen_zero(o->chan->redirecting.from.number)) {
+ /*
+ * The call was not previously redirected so it is
+ * now redirected from this number.
+ */
+ ast_free(o->chan->redirecting.from.number);
+ o->chan->redirecting.from.number =
+ ast_strdup(S_OR(in->macroexten, in->exten));
+ }
o->chan->cid.cid_tns = in->cid.cid_tns;
ast_party_caller_copy(&o->chan->cid, &in->cid);
- ast_party_connected_line_copy(&o->chan->connected, apc);
+ ast_party_connected_line_copy(&o->chan->connected, &original->connected);
- ast_channel_update_redirecting(in, apr);
- if (in->cid.cid_rdnis) {
- ast_free(in->cid.cid_rdnis);
- }
- in->cid.cid_rdnis = ast_strdup(o->chan->cid.cid_rdnis);
+ ast_channel_update_redirecting(in, &o->chan->redirecting);
update_connectedline = 1;