Q.921 TEI assignment procedure corrections.

* We should send the TEI identity denied message with TEI=127 when the TEI
pool is exhausted.

* We should remove our TEI if we see a TEI identity assign message
assigning our TEI to someone else.


git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2104 2fbb986a-6c06-0410-b554-c9c1f0a7f128
This commit is contained in:
Richard Mudgett 2010-11-05 19:59:45 +00:00
parent f7866a2de8
commit de0bf0b50e

26
q921.c
View File

@ -1243,6 +1243,7 @@ static pri_event *q921_receive_MDL(struct pri *ctrl, q921_u *h, int len)
} }
/* XXX : TODO later sometime: Implement the TEI check procedure to reclaim some dead TEIs. */ /* XXX : TODO later sometime: Implement the TEI check procedure to reclaim some dead TEIs. */
pri_error(ctrl, "Reached maximum TEI quota, cannot assign new TEI\n"); pri_error(ctrl, "Reached maximum TEI quota, cannot assign new TEI\n");
q921_send_tei(ctrl, Q921_TEI_IDENTITY_DENIED, ri, Q921_TEI_GROUP, 1);
return NULL; return NULL;
} }
} }
@ -1268,18 +1269,35 @@ static pri_event *q921_receive_MDL(struct pri *ctrl, q921_u *h, int len)
link = ctrl->link.next; link = ctrl->link.next;
switch (link->state) { switch (link->state) {
case Q921_TEI_UNASSIGNED:
/* We do not have a TEI and we are not asking for one. */
return NULL;
case Q921_ASSIGN_AWAITING_TEI: case Q921_ASSIGN_AWAITING_TEI:
case Q921_ESTABLISH_AWAITING_TEI: case Q921_ESTABLISH_AWAITING_TEI:
/* We do not have a TEI and we want one. */
break; break;
default: default:
pri_message(ctrl, "Ignoring unrequested TEI assign message\n"); /* We already have a TEI. */
if (tei == link->tei) {
/*
* The TEI assignment conflicts with ours. Our TEI is the
* duplicate so we should remove it. Q.921 Section 5.3.4.2
* condition c.
*/
pri_error(ctrl, "TEI=%d Conflicting TEI assignment. Removing our TEI.\n",
tei);
q921_mdl_remove(link);
q921_start(link);
}
return NULL; return NULL;
} }
if (ri != link->ri) { if (ri != link->ri) {
pri_message(ctrl, if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
"TEI assignment received for another Ri %02x (ours is %02x)\n", pri_message(ctrl,
ri, link->ri); "TEI assignment received for another Ri %02x (ours is %02x)\n",
ri, link->ri);
}
return NULL; return NULL;
} }