[libpri-commits] rmudgett: branch 1.4 r2078 - in /branches/1.4: pri.c pri_internal.h
SVN commits to the libpri project
libpri-commits at lists.digium.com
Thu Oct 21 12:32:41 CDT 2010
Author: rmudgett
Date: Thu Oct 21 12:32:39 2010
New Revision: 2078
URL: http://svnview.digium.com/svn/libpri?view=rev&rev=2078
Log:
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.
Modified:
branches/1.4/pri.c
branches/1.4/pri_internal.h
Modified: branches/1.4/pri.c
URL: http://svnview.digium.com/svn/libpri/branches/1.4/pri.c?view=diff&rev=2078&r1=2077&r2=2078
==============================================================================
--- branches/1.4/pri.c (original)
+++ branches/1.4/pri.c Thu Oct 21 12:32:39 2010
@@ -1646,11 +1646,43 @@
void pri_enslave(struct pri *master, struct pri *slave)
{
- if (master && slave) {
- slave->callpool = &master->localpool;
- slave->nfas = 1;
- master->nfas = 1;
- }
+ if (!master || !slave) {
+ return;
+ }
+
+ 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)
Modified: branches/1.4/pri_internal.h
URL: http://svnview.digium.com/svn/libpri/branches/1.4/pri_internal.h?view=diff&rev=2078&r1=2077&r2=2078
==============================================================================
--- branches/1.4/pri_internal.h (original)
+++ branches/1.4/pri_internal.h Thu Oct 21 12:32:39 2010
@@ -76,6 +76,10 @@
void *userdata;
/*! Accumulated pri_message() line. (Valid in master record only) */
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 {
/*! Dynamically allocated array of timers that can grow as needed. */
struct pri_sched *timer;
@@ -952,6 +956,21 @@
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.
*
* \param ctrl D channel controller.
More information about the libpri-commits
mailing list