[libpri-commits] mattf: trunk r492 - in /trunk: q921.c q931.c
SVN commits to the libpri project
libpri-commits at lists.digium.com
Tue Dec 4 18:12:54 CST 2007
Author: mattf
Date: Tue Dec 4 18:12:54 2007
New Revision: 492
URL: http://svn.digium.com/view/libpri?view=rev&rev=492
Log:
More PTMP fixes. Stand by, more changes to come
Modified:
trunk/q921.c
trunk/q931.c
Modified: trunk/q921.c
URL: http://svn.digium.com/view/libpri/trunk/q921.c?view=diff&rev=492&r1=491&r2=492
==============================================================================
--- trunk/q921.c (original)
+++ trunk/q921.c Tue Dec 4 18:12:54 2007
@@ -438,10 +438,6 @@
int q921_transmit_iframe(struct pri *pri, void *buf, int len, int cr)
{
q921_frame *f, *prev=NULL;
-
- /* Exception for BRI CPE PTMP */
- if (pri->bri && (pri->localtype == PRI_CPE) && pri->subchannel)
- return q921_transmit_iframe(pri->subchannel, buf, len, cr);
for (f=pri->txqueue; f; f = f->next) prev = f;
f = malloc(sizeof(q921_frame) + len + 2);
@@ -1062,14 +1058,11 @@
#endif
if (!((h->h.sapi == pri->sapi) && ((h->h.tei == pri->tei) || (h->h.tei == Q921_TEI_GROUP)))) {
- /* Check for SAPIs we don't yet handle */
- //if ((h->h.sapi != pri->sapi) || ((h->h.tei != pri->tei) && (h->h.tei != Q921_TEI_GROUP))) {
-//#ifdef PROCESS_SUBCHANNELS
+ /* Check for SAPIs we don't yet handle */
/* If it's not us, try any subchannels we have */
if (pri->subchannel)
return q921_receive(pri->subchannel, h, len + 2);
else
-//#endif
{
pri_error(pri, "Message for SAPI/TEI=%d/%d IS NOT HANDLED\n", h->h.sapi, h->h.tei);
return NULL;
Modified: trunk/q931.c
URL: http://svn.digium.com/view/libpri/trunk/q931.c?view=diff&rev=492&r1=491&r2=492
==============================================================================
--- trunk/q931.c (original)
+++ trunk/q931.c Tue Dec 4 18:12:54 2007
@@ -2177,10 +2177,15 @@
pri_error(pri, "!! %c Unknown IE %d (cs%d, len = %d)\n", prefix, Q931_IE_IE(base_ie), Q931_IE_CODESET(base_ie), ielen(ie));
}
-static q931_call *q931_getcall(struct pri *pri, int cr)
+static q931_call *q931_getcall(struct pri *pri, int cr, int newcall)
{
q931_call *cur, *prev;
- cur = *pri->callpool;
+ struct pri *master;
+
+ /* Find the master - He has the call pool */
+ for (master = pri; master->master; master = master->master);
+
+ cur = *master->callpool;
prev = NULL;
while(cur) {
if (cur->cr == cr)
@@ -2196,12 +2201,17 @@
call_init(cur);
/* Call reference */
cur->cr = cr;
- cur->pri = pri;
+ /* PRI is set to whoever called us */
+ if (pri->bri && (pri->localtype == PRI_CPE) && pri->subchannel && newcall)
+ cur->pri = pri->subchannel;
+ else
+ cur->pri = pri;
+
/* Append to end of list */
if (prev)
prev->next = cur;
else
- *pri->callpool = cur;
+ *master->callpool = cur;
}
return cur;
}
@@ -2209,6 +2219,7 @@
q931_call *q931_new_call(struct pri *pri)
{
q931_call *cur;
+
do {
cur = *pri->callpool;
pri->cref++;
@@ -2225,16 +2236,16 @@
cur = cur->next;
}
} while(cur);
- return q931_getcall(pri, pri->cref | 0x8000);
+
+ return q931_getcall(pri, pri->cref | 0x8000, 1);
}
static void q931_destroy(struct pri *pri, int cr, q931_call *c)
{
q931_call *cur, *prev;
- /* Magic for BRI PTMP CPE */
- if (pri->subchannel && (pri->localtype == PRI_CPE) && pri->bri)
- return q931_destroy(pri->subchannel, cr, c);
+ /* For destroying, make sure we are using the master span, since it maintains the call pool */
+ for (;pri->master; pri = pri->master);
prev = NULL;
cur = *pri->callpool;
@@ -2482,7 +2493,7 @@
}
/* Invert the logic */
len = sizeof(buf) - len;
- q931_xmit(pri, h, len, 1);
+ q931_xmit(c->pri, h, len, 1);
c->acked = 1;
return 0;
}
@@ -2785,7 +2796,7 @@
int q931_restart(struct pri *pri, int channel)
{
struct q931_call *c;
- c = q931_getcall(pri, 0 | 0x8000);
+ c = q931_getcall(pri, 0 | 0x8000, 0);
if (!c)
return -1;
if (!channel)
@@ -3091,7 +3102,7 @@
pri_error(pri, "Warning: unknown/inappropriate protocol discriminator received (%02x/%d)\n", h->pd, h->pd);
return 0;
}
- c = q931_getcall(pri, q931_cr(h));
+ c = q931_getcall(pri, q931_cr(h), 0);
if (!c) {
pri_error(pri, "Unable to locate call %d\n", q931_cr(h));
return -1;
More information about the libpri-commits
mailing list