Fix TE PTMP side sending FACILITY messages on the dummy call reference.

Only the NT PTMP side can send Q.931 broadcast messages.

Also removed an inaccurate comment in Q.921 and made
q921_mdl_handle_error_callback() call the correct struct pri free
function.


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@1426 2fbb986a-6c06-0410-b554-c9c1f0a7f128
This commit is contained in:
Richard Mudgett 2010-01-19 21:53:31 +00:00
parent 79fbecc5ae
commit 7dd6494c61
2 changed files with 11 additions and 19 deletions

3
q921.c
View File

@ -564,7 +564,6 @@ int q921_transmit_iframe(struct pri *vpri, int tei, void *buf, int len, int cr)
if (pri->q921_state == Q921_TEI_UNASSIGNED) { if (pri->q921_state == Q921_TEI_UNASSIGNED) {
q921_tei_request(pri); q921_tei_request(pri);
/* We don't setstate here because the pri with the TEI we need hasn't been created */
q921_setstate(pri, Q921_ESTABLISH_AWAITING_TEI); q921_setstate(pri, Q921_ESTABLISH_AWAITING_TEI);
} }
} else { } else {
@ -1299,7 +1298,7 @@ static void q921_mdl_handle_error_callback(void *vpri)
pri_message(pri, "Freeing TEI of %d\n", freep->tei); pri_message(pri, "Freeing TEI of %d\n", freep->tei);
} }
free(freep); __pri_free_tei(freep);
} }
return; return;

25
q931.c
View File

@ -3969,6 +3969,7 @@ static int send_message(struct pri *ctrl, q931_call *call, int msgtype, int ies[
int offset=0; int offset=0;
int x; int x;
int codeset; int codeset;
int uiframe;
if (call->outboundbroadcast && call->master_call == call && msgtype != Q931_SETUP) { if (call->outboundbroadcast && call->master_call == call && msgtype != Q931_SETUP) {
pri_error(ctrl, pri_error(ctrl,
@ -3997,10 +3998,9 @@ static int send_message(struct pri *ctrl, q931_call *call, int msgtype, int ies[
/* Invert the logic */ /* Invert the logic */
len = sizeof(buf) - len; len = sizeof(buf) - len;
ctrl = call->pri; uiframe = 0;
if (ctrl) { if (BRI_NT_PTMP(ctrl)) {
int uiframe; /* NT PTMP is the only mode that can broadcast Q.931 messages. */
switch (msgtype) { switch (msgtype) {
case Q931_SETUP: case Q931_SETUP:
/* /*
@ -4011,13 +4011,10 @@ static int send_message(struct pri *ctrl, q931_call *call, int msgtype, int ies[
* If those are true, we need to send the SETUP in a UI frame * If those are true, we need to send the SETUP in a UI frame
* instead of an I-frame. * instead of an I-frame.
*/ */
if (BRI_NT_PTMP(ctrl))
uiframe = 1; uiframe = 1;
else
uiframe = 0;
break; break;
case Q931_FACILITY: case Q931_FACILITY:
if (ctrl->tei == Q921_TEI_GROUP) { if (call->pri->tei == Q921_TEI_GROUP) {
/* Broadcast TEI. */ /* Broadcast TEI. */
if (q931_is_dummy_call(call)) { if (q931_is_dummy_call(call)) {
/* /*
@ -4031,23 +4028,19 @@ static int send_message(struct pri *ctrl, q931_call *call, int msgtype, int ies[
msg2str(msgtype), call->cr); msg2str(msgtype), call->cr);
return -1; return -1;
} }
} else {
uiframe = 0;
} }
break; break;
default: default:
uiframe = 0;
break; break;
} }
if (ctrl->debug & PRI_DEBUG_Q931_STATE) { if (ctrl->debug & PRI_DEBUG_Q931_STATE) {
/* This message is only interesting for NT PTMP mode. */
pri_message(ctrl, pri_message(ctrl,
"Sending message for call %p on %p TEI/SAPI %d/%d, call->pri is %p, TEI/SAPI %d/%d\n", "Sending message for call %p on call->pri: %p with TEI/SAPI %d/%d\n",
call, call, call->pri, call->pri->tei, call->pri->sapi);
ctrl, ctrl->tei, ctrl->sapi,
call->pri, call->pri->tei, call->pri->sapi);
} }
q931_xmit(ctrl, ctrl->tei, h, len, 1, uiframe);
} }
q931_xmit(call->pri, call->pri->tei, h, len, 1, uiframe);
call->acked = 1; call->acked = 1;
return 0; return 0;
} }