From 9a7715a09dc2cf3c742a0fcf23324c3b1a150f73 Mon Sep 17 00:00:00 2001 From: Richard Mudgett Date: Wed, 17 Nov 2010 21:32:40 +0000 Subject: [PATCH] Merged revision 2101 from https://origsvn.digium.com/svn/libpri/branches/1.4 .......... r2101 | rmudgett | 2010-11-05 14:24:01 -0500 (Fri, 05 Nov 2010) | 9 lines Remove all TEIs when NT PTMP starts. Remove all TEIs when a NT PTMP link is started and there are no other links to make sure there are no devices that think they have a TEI. A device may think it has a TEI if the upper layer program is restarted or the system reboots. This fixes the bug portion of JIRA LIBPRI-51/SWP-2453. .......... git-svn-id: https://origsvn.digium.com/svn/libpri/tags/1.4.11.5@2139 2fbb986a-6c06-0410-b554-c9c1f0a7f128 --- q921.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/q921.c b/q921.c index 3d9c34c..05b8acc 100644 --- a/q921.c +++ b/q921.c @@ -235,6 +235,16 @@ static void q921_tei_request(struct pri *ctrl) t202_expire(ctrl); } +static void q921_tei_remove(struct pri *ctrl, int tei) +{ + /* + * Q.921 Section 5.3.2 says we should send the remove message + * twice, in case of message loss. + */ + q921_send_tei(ctrl, Q921_TEI_IDENTITY_REMOVE, 0, tei, 1); + q921_send_tei(ctrl, Q921_TEI_IDENTITY_REMOVE, 0, tei, 1); +} + static void q921_send_dm(struct pri *ctrl, int fbit) { q921_h h; @@ -2455,9 +2465,7 @@ static pri_event *q921_handle_unmatched_frame(struct pri *ctrl, q921_h *h, int l pri_message(ctrl, "Sending TEI release, in order to re-establish TEI state\n"); } - /* Q.921 says we should send the remove message twice, in case of link corruption */ - q921_send_tei(ctrl, Q921_TEI_IDENTITY_REMOVE, 0, h->h.tei, 1); - q921_send_tei(ctrl, Q921_TEI_IDENTITY_REMOVE, 0, h->h.tei, 1); + q921_tei_remove(ctrl, h->h.tei); } return NULL; @@ -2556,6 +2564,16 @@ void q921_start(struct pri *ctrl) } else { q921_setstate(ctrl, Q921_TEI_UNASSIGNED); pri_schedule_event(ctrl, 0, nt_ptmp_dchannel_up, ctrl); + ctrl = PRI_MASTER(ctrl); + if (!ctrl->subchannel) { + /* + * We do not have any TEI's so make sure there are no devices + * that think they have a TEI. A device may think it has a TEI + * if the upper layer program is restarted or the system + * reboots. + */ + q921_tei_remove(ctrl, Q921_TEI_GROUP); + } } } else { /* PTP mode, no need for TEI management junk */