diff --git a/libpri.h b/libpri.h index f1bec9f..9fdea60 100755 --- a/libpri.h +++ b/libpri.h @@ -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 diff --git a/pri.c b/pri.c index d1a26bb..c17de50 100755 --- a/pri.c +++ b/pri.c @@ -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; +} diff --git a/pri_internal.h b/pri_internal.h index 8684697..deb5ec3 100755 --- a/pri_internal.h +++ b/pri_internal.h @@ -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; diff --git a/q931.c b/q931.c index 0f88f6e..8c8b12a 100755 --- a/q931.c +++ b/q931.c @@ -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;