Convert most references of Q931_MAX_TEI to use ARRAY_LEN().
* Minor comment correction in q931_destroycall(). * Redundant logic removal q931_destroycall(). "W && X && (Y || W && Z)" is the same as "W && X && (Y || Z)" git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@1912 2fbb986a-6c06-0410-b554-c9c1f0a7f128
This commit is contained in:
parent
28b3a8f458
commit
e12b0913ec
4
pri.c
4
pri.c
@ -832,7 +832,7 @@ int pri_connected_line_update(struct pri *ctrl, q931_call *call, const struct pr
|
|||||||
|
|
||||||
/* Update all subcalls with new local_id. */
|
/* Update all subcalls with new local_id. */
|
||||||
if (call->outboundbroadcast && call->master_call == call) {
|
if (call->outboundbroadcast && call->master_call == call) {
|
||||||
for (idx = 0; idx < Q931_MAX_TEI; ++idx) {
|
for (idx = 0; idx < ARRAY_LEN(call->subcalls); ++idx) {
|
||||||
subcall = call->subcalls[idx];
|
subcall = call->subcalls[idx];
|
||||||
if (subcall) {
|
if (subcall) {
|
||||||
subcall->local_id = party_id;
|
subcall->local_id = party_id;
|
||||||
@ -899,7 +899,7 @@ int pri_redirecting_update(struct pri *ctrl, q931_call *call, const struct pri_p
|
|||||||
* but update it just in case.
|
* but update it just in case.
|
||||||
*/
|
*/
|
||||||
if (call->outboundbroadcast && call->master_call == call) {
|
if (call->outboundbroadcast && call->master_call == call) {
|
||||||
for (idx = 0; idx < Q931_MAX_TEI; ++idx) {
|
for (idx = 0; idx < ARRAY_LEN(call->subcalls); ++idx) {
|
||||||
subcall = call->subcalls[idx];
|
subcall = call->subcalls[idx];
|
||||||
if (subcall) {
|
if (subcall) {
|
||||||
subcall->redirecting.to = call->redirecting.to;
|
subcall->redirecting.to = call->redirecting.to;
|
||||||
|
30
q931.c
30
q931.c
@ -3956,7 +3956,7 @@ void q931_destroycall(struct pri *ctrl, q931_call *c)
|
|||||||
if (cur == c) {
|
if (cur == c) {
|
||||||
slaveidx = -1;
|
slaveidx = -1;
|
||||||
if (slave) {
|
if (slave) {
|
||||||
for (i = 0; i < Q931_MAX_TEI; i++) {
|
for (i = 0; i < ARRAY_LEN(cur->subcalls); ++i) {
|
||||||
if (cur->subcalls[i] == slave) {
|
if (cur->subcalls[i] == slave) {
|
||||||
if (ctrl->debug & PRI_DEBUG_Q931_STATE) {
|
if (ctrl->debug & PRI_DEBUG_Q931_STATE) {
|
||||||
pri_message(ctrl, "Destroying subcall %p of call %p at %d\n",
|
pri_message(ctrl, "Destroying subcall %p of call %p at %d\n",
|
||||||
@ -3971,7 +3971,7 @@ void q931_destroycall(struct pri *ctrl, q931_call *c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
slavesleft = 0;
|
slavesleft = 0;
|
||||||
for (i = 0; i < Q931_MAX_TEI; i++) {
|
for (i = 0; i < ARRAY_LEN(cur->subcalls); ++i) {
|
||||||
if (cur->subcalls[i]) {
|
if (cur->subcalls[i]) {
|
||||||
if (ctrl->debug & PRI_DEBUG_Q931_STATE) {
|
if (ctrl->debug & PRI_DEBUG_Q931_STATE) {
|
||||||
pri_message(ctrl, "Subcall still present at %d\n", i);
|
pri_message(ctrl, "Subcall still present at %d\n", i);
|
||||||
@ -3981,8 +3981,8 @@ void q931_destroycall(struct pri *ctrl, q931_call *c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* We have 3 different phases to deal with:
|
/* We have 3 different phases to deal with:
|
||||||
* 1.) Sent outbound call, but no response, indicated by t203 present
|
* 1.) Sent outbound call, but no response (no subcalls present)
|
||||||
* 2.) Sent outbound call, with responses, indicated by lack of t203 and subcalls present
|
* 2.) Sent outbound call, with responses (subcalls present)
|
||||||
* 3.) Outbound call connected, indicated by pri_winner > -1
|
* 3.) Outbound call connected, indicated by pri_winner > -1
|
||||||
*
|
*
|
||||||
* If chan_dahdi hangs up in phase:
|
* If chan_dahdi hangs up in phase:
|
||||||
@ -4005,7 +4005,7 @@ void q931_destroycall(struct pri *ctrl, q931_call *c)
|
|||||||
* If, when the library user hangs up the master call, and there are more than one subcall up, we fake clear
|
* If, when the library user hangs up the master call, and there are more than one subcall up, we fake clear
|
||||||
* regardless of whether or not we drop down to one subcall left in the clearing process.
|
* regardless of whether or not we drop down to one subcall left in the clearing process.
|
||||||
*
|
*
|
||||||
* If there are only one call up, we mirror what it does.
|
* If there is only one call up, we mirror what it does.
|
||||||
*
|
*
|
||||||
* OR
|
* OR
|
||||||
*
|
*
|
||||||
@ -4023,8 +4023,8 @@ void q931_destroycall(struct pri *ctrl, q931_call *c)
|
|||||||
* call as dead and free it when the last subcall clears.
|
* call as dead and free it when the last subcall clears.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if ((slave && !slavesleft) &&
|
if (slave && !slavesleft /* i.e., The last slave was just destroyed */
|
||||||
((cur->pri_winner < 0) || (slave && slaveidx != cur->pri_winner))) {
|
&& (cur->pri_winner < 0 || slaveidx != cur->pri_winner)) {
|
||||||
pri_create_fake_clearing(cur, ctrl);
|
pri_create_fake_clearing(cur, ctrl);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -4606,7 +4606,7 @@ int q931_notify_redirection(struct pri *ctrl, q931_call *call, int notify, const
|
|||||||
|
|
||||||
if (call->outboundbroadcast && call->master_call == call) {
|
if (call->outboundbroadcast && call->master_call == call) {
|
||||||
status = 0;
|
status = 0;
|
||||||
for (idx = 0; idx < Q931_MAX_TEI; ++idx) {
|
for (idx = 0; idx < ARRAY_LEN(call->subcalls); ++idx) {
|
||||||
subcall = call->subcalls[idx];
|
subcall = call->subcalls[idx];
|
||||||
if (subcall) {
|
if (subcall) {
|
||||||
/* Send to all subcalls that have given a positive response. */
|
/* Send to all subcalls that have given a positive response. */
|
||||||
@ -5996,7 +5996,7 @@ int q931_hangup(struct pri *ctrl, q931_call *call, int cause)
|
|||||||
int slaves = 0;
|
int slaves = 0;
|
||||||
|
|
||||||
/* Master is called with hangup - initiate hangup with slaves */
|
/* Master is called with hangup - initiate hangup with slaves */
|
||||||
for (i = 0; i < Q931_MAX_TEI; i++) {
|
for (i = 0; i < ARRAY_LEN(call->subcalls); ++i) {
|
||||||
if (call->subcalls[i]) {
|
if (call->subcalls[i]) {
|
||||||
slaves++;
|
slaves++;
|
||||||
if (i == call->master_call->pri_winner) {
|
if (i == call->master_call->pri_winner) {
|
||||||
@ -6248,7 +6248,7 @@ static int q931_get_subcall_count(struct q931_call *call)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
call = call->master_call;
|
call = call->master_call;
|
||||||
for (i = 0; i < Q931_MAX_TEI; i++) {
|
for (i = 0; i < ARRAY_LEN(call->subcalls); ++i) {
|
||||||
if (call->subcalls[i])
|
if (call->subcalls[i])
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
@ -6263,7 +6263,7 @@ static void q931_set_subcall_winner(struct q931_call *subcall)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
/* Set the winner first */
|
/* Set the winner first */
|
||||||
for (i = 0; i < Q931_MAX_TEI; i++) {
|
for (i = 0; i < ARRAY_LEN(realcall->subcalls); ++i) {
|
||||||
if (realcall->subcalls[i] && realcall->subcalls[i] == subcall) {
|
if (realcall->subcalls[i] && realcall->subcalls[i] == subcall) {
|
||||||
realcall->pri_winner = i;
|
realcall->pri_winner = i;
|
||||||
}
|
}
|
||||||
@ -6274,7 +6274,7 @@ static void q931_set_subcall_winner(struct q931_call *subcall)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Start tear down of calls that were not chosen */
|
/* Start tear down of calls that were not chosen */
|
||||||
for (i = 0; i < Q931_MAX_TEI; i++) {
|
for (i = 0; i < ARRAY_LEN(realcall->subcalls); ++i) {
|
||||||
if (realcall->subcalls[i] && realcall->subcalls[i] != subcall) {
|
if (realcall->subcalls[i] && realcall->subcalls[i] != subcall) {
|
||||||
initiate_hangup_if_needed(realcall->subcalls[i]->pri, realcall->subcalls[i],
|
initiate_hangup_if_needed(realcall->subcalls[i]->pri, realcall->subcalls[i],
|
||||||
PRI_CAUSE_NONSELECTED_USER_CLEARING);
|
PRI_CAUSE_NONSELECTED_USER_CLEARING);
|
||||||
@ -6289,7 +6289,7 @@ static struct q931_call *q931_get_subcall(struct pri *ctrl, struct q931_call *ma
|
|||||||
int firstfree = -1;
|
int firstfree = -1;
|
||||||
|
|
||||||
/* First try to locate our subcall */
|
/* First try to locate our subcall */
|
||||||
for (i = 0; i < Q931_MAX_TEI; i++) {
|
for (i = 0; i < ARRAY_LEN(master_call->subcalls); ++i) {
|
||||||
if (master_call->subcalls[i]) {
|
if (master_call->subcalls[i]) {
|
||||||
if (master_call->subcalls[i]->pri == ctrl) {
|
if (master_call->subcalls[i]->pri == ctrl) {
|
||||||
return master_call->subcalls[i];
|
return master_call->subcalls[i];
|
||||||
@ -6300,7 +6300,7 @@ static struct q931_call *q931_get_subcall(struct pri *ctrl, struct q931_call *ma
|
|||||||
}
|
}
|
||||||
if (firstfree < 0) {
|
if (firstfree < 0) {
|
||||||
pri_error(ctrl, "Tried to add more than %d TEIs to call and failed\n",
|
pri_error(ctrl, "Tried to add more than %d TEIs to call and failed\n",
|
||||||
Q931_MAX_TEI);
|
(int) ARRAY_LEN(master_call->subcalls));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6316,7 +6316,7 @@ static struct q931_call *q931_get_subcall(struct pri *ctrl, struct q931_call *ma
|
|||||||
cur->apdus = NULL;
|
cur->apdus = NULL;
|
||||||
cur->bridged_call = NULL;
|
cur->bridged_call = NULL;
|
||||||
//cur->master_call = master_call; /* We get this assignment for free. */
|
//cur->master_call = master_call; /* We get this assignment for free. */
|
||||||
for (i = 0; i < Q931_MAX_TEI; ++i) {
|
for (i = 0; i < ARRAY_LEN(cur->subcalls); ++i) {
|
||||||
cur->subcalls[i] = NULL;
|
cur->subcalls[i] = NULL;
|
||||||
}
|
}
|
||||||
cur->t303_timer = 0;/* T303 should only be on on the master call */
|
cur->t303_timer = 0;/* T303 should only be on on the master call */
|
||||||
|
Loading…
Reference in New Issue
Block a user