[libpri-commits] mattf: trunk r541 - in /trunk: pri.c pri_q921.h q921.c
SVN commits to the libpri project
libpri-commits at lists.digium.com
Fri Mar 14 17:12:03 CDT 2008
Author: mattf
Date: Fri Mar 14 17:12:03 2008
New Revision: 541
URL: http://svn.digium.com/view/libpri?view=rev&rev=541
Log:
When we recieve a UA in any TEI established state other than awaiting establishement make sure we drop the TEI and get a new one. For passing tests PC37.2 - PC41.2 in Q.921
Modified:
trunk/pri.c
trunk/pri_q921.h
trunk/q921.c
Modified: trunk/pri.c
URL: http://svn.digium.com/view/libpri/trunk/pri.c?view=diff&rev=541&r1=540&r2=541
==============================================================================
--- trunk/pri.c (original)
+++ trunk/pri.c Fri Mar 14 17:12:03 2008
@@ -201,7 +201,6 @@
if (!(p = calloc(1, sizeof(*p))))
return NULL;
- pri_error(NULL, "Making new tei %d\n", tei);
p->bri = bri;
p->fd = fd;
p->read_func = rd;
Modified: trunk/pri_q921.h
URL: http://svn.digium.com/view/libpri/trunk/pri_q921.h?view=diff&rev=541&r1=540&r2=541
==============================================================================
--- trunk/pri_q921.h (original)
+++ trunk/pri_q921.h Fri Mar 14 17:12:03 2008
@@ -163,7 +163,7 @@
#define Q921_INC(j) (j) = (((j) + 1) % 128)
typedef enum q921_state {
- Q921_DOWN,
+ Q921_DOWN = 0,
Q921_TEI_UNASSIGNED,
Q921_TEI_AWAITING_ESTABLISH,
Q921_TEI_AWAITING_ASSIGN,
Modified: trunk/q921.c
URL: http://svn.digium.com/view/libpri/trunk/q921.c?view=diff&rev=541&r1=540&r2=541
==============================================================================
--- trunk/q921.c (original)
+++ trunk/q921.c Fri Mar 14 17:12:03 2008
@@ -766,6 +766,15 @@
q921_discard_retransmissions(pri);
}
+static void q921_tei_release_and_reacquire(struct pri *master)
+{
+ /* Make sure the master is passed into this function */
+ q921_dchannel_down(master->subchannel);
+ __pri_free_tei(master->subchannel);
+ master->subchannel = NULL;
+ q921_start(master, master->localtype == PRI_CPE);
+}
+
static pri_event *q921_receive_MDL(struct pri *pri, q921_u *h, int len)
{
int ri;
@@ -814,10 +823,7 @@
}
if (pri->subchannel && (pri->subchannel->tei == tei)) {
pri_error(pri, "TEI already assigned (new is %d, current is %d)\n", tei, pri->subchannel->tei);
- q921_dchannel_down(pri->subchannel);
- __pri_free_tei(pri->subchannel);
- pri->subchannel = NULL;
- q921_start(pri, pri->localtype == PRI_CPE);
+ q921_tei_release_and_reacquire(pri);
return NULL;
}
@@ -847,10 +853,7 @@
return NULL;
if ((tei == Q921_TEI_GROUP) || (tei == pri->subchannel->tei)) {
- q921_dchannel_down(pri->subchannel);
- __pri_free_tei(pri->subchannel);
- pri->subchannel = NULL;
- q921_start(pri, pri->localtype == PRI_CPE);
+ q921_tei_release_and_reacquire(pri);
}
}
return NULL; /* Do we need to return something??? */
@@ -1043,8 +1046,17 @@
pri_message(pri, "-- Got UA from %s peer Link up.\n", h->h.c_r ? "cpe" : "network");
}
return q921_dchannel_up(pri);
- } else
+ } else if ((pri->q921_state >= Q921_TEI_ASSIGNED) && pri->bri) {
+ /* Possible duplicate TEI assignment */
+ if (pri->master)
+ q921_tei_release_and_reacquire(pri->master);
+ else
+ pri_error(pri, "Huh!? no master found\n");
+ } else {
+ /* Since we're not in the AWAITING_ESTABLISH STATE, it's unsolicited */
pri_error(pri, "!! Got a UA, but i'm in state %d\n", pri->q921_state);
+
+ }
} else
pri_error(pri, "!! Weird frame received (m3=3, m2 = %d)\n", h->u.m2);
break;
More information about the libpri-commits
mailing list