Partial support for dynamic interfaces with NFAS.
To have some support for dynamic interfaces, the master NFAS D channel control structure will always exist even if it is abandoned/deleted by the upper layer. The master/slave pointers ensure that the correct master will be used. git-svn-id: https://origsvn.digium.com/svn/libpri/branches/1.4@2078 2fbb986a-6c06-0410-b554-c9c1f0a7f128
This commit is contained in:
parent
f9c3c8d026
commit
5923df047d
40
pri.c
40
pri.c
@ -1646,11 +1646,43 @@ int pri_set_crv(struct pri *pri, q931_call *call, int crv, int callmode)
|
|||||||
|
|
||||||
void pri_enslave(struct pri *master, struct pri *slave)
|
void pri_enslave(struct pri *master, struct pri *slave)
|
||||||
{
|
{
|
||||||
if (master && slave) {
|
if (!master || !slave) {
|
||||||
slave->callpool = &master->localpool;
|
return;
|
||||||
slave->nfas = 1;
|
|
||||||
master->nfas = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (slave->master) {
|
||||||
|
struct pri *swp;
|
||||||
|
|
||||||
|
/* The slave already has a master */
|
||||||
|
if (master->master || master->slave) {
|
||||||
|
/* The new master has a master or it already has slaves. */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Swap master and slave. */
|
||||||
|
swp = master;
|
||||||
|
master = slave;
|
||||||
|
slave = master;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* To have some support for dynamic interfaces, the master NFAS
|
||||||
|
* D channel control structure will always exist even if it is
|
||||||
|
* abandoned/deleted by the upper layer. The master/slave
|
||||||
|
* pointers ensure that the correct master will be used.
|
||||||
|
*/
|
||||||
|
|
||||||
|
master = PRI_NFAS_MASTER(master);
|
||||||
|
master->nfas = 1;
|
||||||
|
slave->nfas = 1;
|
||||||
|
slave->callpool = &master->localpool;
|
||||||
|
|
||||||
|
/* Link the slave to the master on the end of the master's list. */
|
||||||
|
slave->master = master;
|
||||||
|
slave->slave = NULL;
|
||||||
|
for (; master->slave; master = master->slave) {
|
||||||
|
}
|
||||||
|
master->slave = slave;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct pri_sr *pri_sr_new(void)
|
struct pri_sr *pri_sr_new(void)
|
||||||
|
@ -76,6 +76,10 @@ struct pri {
|
|||||||
void *userdata;
|
void *userdata;
|
||||||
/*! Accumulated pri_message() line. (Valid in master record only) */
|
/*! Accumulated pri_message() line. (Valid in master record only) */
|
||||||
struct pri_msg_line *msg_line;
|
struct pri_msg_line *msg_line;
|
||||||
|
/*! NFAS master/primary channel if appropriate */
|
||||||
|
struct pri *master;
|
||||||
|
/*! Next NFAS slaved D channel if appropriate */
|
||||||
|
struct pri *slave;
|
||||||
struct {
|
struct {
|
||||||
/*! Dynamically allocated array of timers that can grow as needed. */
|
/*! Dynamically allocated array of timers that can grow as needed. */
|
||||||
struct pri_sched *timer;
|
struct pri_sched *timer;
|
||||||
@ -951,6 +955,21 @@ int pri_cc_event(struct pri *ctrl, q931_call *call, struct pri_cc_record *cc_rec
|
|||||||
int q931_cc_timeout(struct pri *ctrl, struct pri_cc_record *cc_record, enum CC_EVENTS event);
|
int q931_cc_timeout(struct pri *ctrl, struct pri_cc_record *cc_record, enum CC_EVENTS event);
|
||||||
void q931_cc_indirect(struct pri *ctrl, struct pri_cc_record *cc_record, void (*func)(struct pri *ctrl, q931_call *call, struct pri_cc_record *cc_record));
|
void q931_cc_indirect(struct pri *ctrl, struct pri_cc_record *cc_record, void (*func)(struct pri *ctrl, q931_call *call, struct pri_cc_record *cc_record));
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Get the NFAS master PRI control structure.
|
||||||
|
*
|
||||||
|
* \param ctrl D channel controller.
|
||||||
|
*
|
||||||
|
* \return NFAS master PRI control structure.
|
||||||
|
*/
|
||||||
|
static inline struct pri *PRI_NFAS_MASTER(struct pri *ctrl)
|
||||||
|
{
|
||||||
|
while (ctrl->master) {
|
||||||
|
ctrl = ctrl->master;
|
||||||
|
}
|
||||||
|
return ctrl;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Determine if layer 2 is in BRI NT PTMP mode.
|
* \brief Determine if layer 2 is in BRI NT PTMP mode.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user