Add the ability to slave one PRI to another with respect to calls

git-svn-id: https://origsvn.digium.com/svn/libpri/trunk@104 2fbb986a-6c06-0410-b554-c9c1f0a7f128
This commit is contained in:
Mark Spencer 2004-06-07 03:33:51 +00:00
parent 551f0fafc8
commit d0c78dd62d
4 changed files with 20 additions and 7 deletions

View File

@ -405,5 +405,10 @@ extern int pri_progress(struct pri *pri, q931_call *c, int channel, int info);
/* Send call proceeding */
extern int pri_proceeding(struct pri *pri, q931_call *c, int channel, int info);
/* Enslave a PRI to another, so they share the same call list
(and maybe some timers) */
extern void pri_enslave(struct pri *master, struct pri *slave);
#define PRI_GR303_SUPPORT
#define PRI_ENSLAVE_SUPPORT
#endif

7
pri.c
View File

@ -76,6 +76,7 @@ static struct pri *__pri_new(int fd, int node, int switchtype, struct pri *maste
p->tei = 0;
p->protodisc = Q931_PROTOCOL_DISCRIMINATOR;
p->master = master;
p->callpool = &p->localpool;
#ifdef LIBPRI_COUNTERS
p->q921_rxcount = 0;
p->q921_txcount = 0;
@ -444,3 +445,9 @@ int pri_set_crv(struct pri *pri, q931_call *call, int crv, int callmode)
{
return q931_call_setcrv(pri, call, crv, callmode);
}
void pri_enslave(struct pri *master, struct pri *slave)
{
if (master && slave)
slave->callpool = &master->localpool;
}

View File

@ -85,7 +85,8 @@ struct pri {
struct q921_frame *txqueue;
/* Q.931 calls */
q931_call *calls;
q931_call **callpool;
q931_call *localpool;
/* do we do overlap dialing */
int overlapdial;

12
q931.c
View File

@ -1310,7 +1310,7 @@ static inline void q931_dumpie(q931_ie *ie, char prefix)
static q931_call *q931_getcall(struct pri *pri, int cr)
{
q931_call *cur, *prev;
cur = pri->calls;
cur = *pri->callpool;
prev = NULL;
while(cur) {
if (cur->cr == cr)
@ -1331,7 +1331,7 @@ static q931_call *q931_getcall(struct pri *pri, int cr)
if (prev)
prev->next = cur;
else
pri->calls = cur;
*pri->callpool = cur;
}
return cur;
}
@ -1340,7 +1340,7 @@ q931_call *q931_new_call(struct pri *pri)
{
q931_call *cur;
do {
cur = pri->calls;
cur = *pri->callpool;
pri->cref++;
if (pri->cref > 32767)
pri->cref = 1;
@ -1357,13 +1357,13 @@ static void q931_destroy(struct pri *pri, int cr, q931_call *c)
{
q931_call *cur, *prev;
prev = NULL;
cur = pri->calls;
cur = *pri->callpool;
while(cur) {
if ((c && (cur == c)) || (!c && (cur->cr == cr))) {
if (prev)
prev->next = cur->next;
else
pri->calls = cur->next;
*pri->callpool = cur->next;
if (pri->debug & PRI_DEBUG_Q931_STATE)
pri_message("NEW_HANGUP DEBUG: Destroying the call, ourstate %s, peerstate %s\n",callstate2str(cur->ourcallstate),callstate2str(cur->peercallstate));
if (cur->retranstimer)
@ -1550,7 +1550,7 @@ static int q931_status(struct pri *pri, q931_call *c, int cause)
if (!cause)
cause = PRI_CAUSE_RESPONSE_TO_STATUS_ENQUIRY;
if (c->cr > -1)
cur = pri->calls;
cur = *pri->callpool;
while(cur) {
if (cur->cr == c->cr) {
cur->cause=cause;