From 948625318acddfebb4db53b0557226080dba98cc Mon Sep 17 00:00:00 2001 From: Richard Mudgett Date: Fri, 5 Nov 2010 19:24:01 +0000 Subject: [PATCH] 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/branches/1.4@2101 2fbb986a-6c06-0410-b554-c9c1f0a7f128 --- q921.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/q921.c b/q921.c index 9f081e5..ad2cd95 100644 --- a/q921.c +++ b/q921.c @@ -241,6 +241,16 @@ static void q921_tei_request(struct q921_link *link) t202_expire(link); } +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 q921_link *link, int fbit) { q921_h h; @@ -2588,9 +2598,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; @@ -2694,6 +2702,15 @@ void q921_start(struct q921_link *link) } else { q921_setstate(link, Q921_TEI_UNASSIGNED); pri_schedule_event(ctrl, 0, nt_ptmp_dchannel_up, ctrl); + if (!ctrl->link.next) { + /* + * 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 */