[libpri-commits] rmudgett: branch rmudgett/link_struct r2049 - /team/rmudgett/link_struct/

SVN commits to the libpri project libpri-commits at lists.digium.com
Mon Oct 18 17:50:58 CDT 2010


Author: rmudgett
Date: Mon Oct 18 17:50:55 2010
New Revision: 2049

URL: http://svnview.digium.com/svn/libpri?view=rev&rev=2049
Log:
Collect Q.921 link members into a substructure for extraction into their own object.

Modified:
    team/rmudgett/link_struct/pri.c
    team/rmudgett/link_struct/pri_cc.c
    team/rmudgett/link_struct/pri_facility.c
    team/rmudgett/link_struct/pri_internal.h
    team/rmudgett/link_struct/q921.c
    team/rmudgett/link_struct/q931.c

Modified: team/rmudgett/link_struct/pri.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/link_struct/pri.c?view=diff&rev=2049&r1=2048&r2=2049
==============================================================================
--- team/rmudgett/link_struct/pri.c (original)
+++ team/rmudgett/link_struct/pri.c Mon Oct 18 17:50:55 2010
@@ -290,7 +290,7 @@
 	if (p) {
 		struct q931_call *call;
 
-		call = p->dummy_call;
+		call = p->link.dummy_call;
 		if (call) {
 			pri_schedule_del(call->pri, call->retranstimer);
 			call->retranstimer = 0;
@@ -357,8 +357,9 @@
 	p->localtype = node;
 	p->switchtype = switchtype;
 	p->cref = 1;
-	p->sapi = (tei == Q921_TEI_GROUP) ? Q921_SAPI_LAYER2_MANAGEMENT : Q921_SAPI_CALL_CTRL;
-	p->tei = tei;
+	p->link.sapi = (tei == Q921_TEI_GROUP) ? Q921_SAPI_LAYER2_MANAGEMENT : Q921_SAPI_CALL_CTRL;
+	p->link.tei = tei;
+	p->link.ctrl = master ? master : p;
 	p->nsf = PRI_NSF_NONE;
 	p->protodisc = Q931_PROTOCOL_DISCRIMINATOR;
 	p->master = master;
@@ -378,15 +379,15 @@
 #endif
 	if (dummy_ctrl) {
 		/* Initialize the dummy call reference call record. */
-		dummy_ctrl->ctrl.dummy_call = &dummy_ctrl->dummy_call;
-		q931_init_call_record(&dummy_ctrl->ctrl, dummy_ctrl->ctrl.dummy_call,
+		dummy_ctrl->ctrl.link.dummy_call = &dummy_ctrl->dummy_call;
+		q931_init_call_record(&dummy_ctrl->ctrl, dummy_ctrl->ctrl.link.dummy_call,
 			Q931_DUMMY_CALL_REFERENCE);
 	}
 	switch (switchtype) {
 	case PRI_SWITCH_GR303_EOC:
 		p->protodisc = GR303_PROTOCOL_DISCRIMINATOR;
-		p->sapi = Q921_SAPI_GR303_EOC;
-		p->tei = Q921_TEI_GR303_EOC_OPS;
+		p->link.sapi = Q921_SAPI_GR303_EOC;
+		p->link.tei = Q921_TEI_GR303_EOC_OPS;
 		p->subchannel = __pri_new_tei(-1, node, PRI_SWITCH_GR303_EOC_PATH, p, NULL, NULL, NULL, Q921_TEI_GR303_EOC_PATH, 0);
 		if (!p->subchannel) {
 			free(p);
@@ -395,8 +396,8 @@
 		break;
 	case PRI_SWITCH_GR303_TMC:
 		p->protodisc = GR303_PROTOCOL_DISCRIMINATOR;
-		p->sapi = Q921_SAPI_GR303_TMC_CALLPROC;
-		p->tei = Q921_TEI_GR303_TMC_CALLPROC;
+		p->link.sapi = Q921_SAPI_GR303_TMC_CALLPROC;
+		p->link.tei = Q921_TEI_GR303_TMC_CALLPROC;
 		p->subchannel = __pri_new_tei(-1, node, PRI_SWITCH_GR303_TMC_SWITCHING, p, NULL, NULL, NULL, Q921_TEI_GR303_TMC_SWITCHING, 0);
 		if (!p->subchannel) {
 			free(p);
@@ -405,19 +406,19 @@
 		break;
 	case PRI_SWITCH_GR303_TMC_SWITCHING:
 		p->protodisc = GR303_PROTOCOL_DISCRIMINATOR;
-		p->sapi = Q921_SAPI_GR303_TMC_SWITCHING;
-		p->tei = Q921_TEI_GR303_TMC_SWITCHING;
+		p->link.sapi = Q921_SAPI_GR303_TMC_SWITCHING;
+		p->link.tei = Q921_TEI_GR303_TMC_SWITCHING;
 		break;
 	case PRI_SWITCH_GR303_EOC_PATH:
 		p->protodisc = GR303_PROTOCOL_DISCRIMINATOR;
-		p->sapi = Q921_SAPI_GR303_EOC;
-		p->tei = Q921_TEI_GR303_EOC_PATH;
+		p->link.sapi = Q921_SAPI_GR303_EOC;
+		p->link.tei = Q921_TEI_GR303_EOC_PATH;
 		break;
 	default:
 		break;
 	}
 
-	if (p->tei == Q921_TEI_GROUP && p->sapi == Q921_SAPI_LAYER2_MANAGEMENT
+	if (p->link.tei == Q921_TEI_GROUP && p->link.sapi == Q921_SAPI_LAYER2_MANAGEMENT
 		&& p->localtype == PRI_CPE) {
 		p->subchannel = __pri_new_tei(-1, p->localtype, p->switchtype, p, NULL, NULL, NULL, Q921_TEI_PRI, 1);
 		if (!p->subchannel) {
@@ -430,7 +431,7 @@
 		 * to broadcast messages on the dummy call or to broadcast any
 		 * messages for that matter.
 		 */
-		p->dummy_call = p->subchannel->dummy_call;
+		p->link.dummy_call = p->subchannel->link.dummy_call;
 	} else
 		q921_start(p);
 	
@@ -1509,11 +1510,11 @@
 	used = pri_snprintf(buf, used, buf_size, "Q921 TX: %d\n", ctrl->q921_txcount);
 	for (link = ctrl; link; link = link->subchannel) {
 		q921outstanding = 0;
-		for (f = link->txqueue; f; f = f->next) {
+		for (f = link->link.tx_queue; f; f = f->next) {
 			++q921outstanding;
 		}
 		used = pri_snprintf(buf, used, buf_size, "Q921 Outstanding: %u (TEI=%d)\n",
-			q921outstanding, link->tei);
+			q921outstanding, link->link.tei);
 	}
 #endif
 #if 0

Modified: team/rmudgett/link_struct/pri_cc.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/link_struct/pri_cc.c?view=diff&rev=2049&r1=2048&r2=2049
==============================================================================
--- team/rmudgett/link_struct/pri_cc.c (original)
+++ team/rmudgett/link_struct/pri_cc.c Mon Oct 18 17:50:55 2010
@@ -6850,7 +6850,7 @@
 				break;
 			}
 			cc_record->call_linkage_id = linkage_id;
-			cc_record->signaling = PRI_MASTER(ctrl)->dummy_call;
+			cc_record->signaling = PRI_MASTER(ctrl)->link.dummy_call;
 		} else {
 			cc_record = pri_cc_new_record(ctrl, call);
 			if (!cc_record) {

Modified: team/rmudgett/link_struct/pri_facility.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/link_struct/pri_facility.c?view=diff&rev=2049&r1=2048&r2=2049
==============================================================================
--- team/rmudgett/link_struct/pri_facility.c (original)
+++ team/rmudgett/link_struct/pri_facility.c Mon Oct 18 17:50:55 2010
@@ -1859,7 +1859,7 @@
 		if (!BRI_NT_PTMP(ctrl)) {
 			return -1;
 		}
-		call = PRI_MASTER(ctrl)->dummy_call;
+		call = PRI_MASTER(ctrl)->link.dummy_call;
 		if (!call) {
 			return -1;
 		}
@@ -3882,7 +3882,7 @@
 		 * Look for the original invocation message on the
 		 * broadcast dummy call reference call first.
 		 */
-		orig_call = PRI_MASTER(ctrl)->dummy_call;
+		orig_call = PRI_MASTER(ctrl)->link.dummy_call;
 		if (orig_call) {
 			apdu = pri_call_apdu_find(orig_call, reject->invoke_id);
 		}
@@ -3966,7 +3966,7 @@
 		 * Look for the original invocation message on the
 		 * broadcast dummy call reference call first.
 		 */
-		orig_call = PRI_MASTER(ctrl)->dummy_call;
+		orig_call = PRI_MASTER(ctrl)->link.dummy_call;
 		if (orig_call) {
 			apdu = pri_call_apdu_find(orig_call, error->invoke_id);
 		}
@@ -4042,7 +4042,7 @@
 		 * Look for the original invocation message on the
 		 * broadcast dummy call reference call first.
 		 */
-		orig_call = PRI_MASTER(ctrl)->dummy_call;
+		orig_call = PRI_MASTER(ctrl)->link.dummy_call;
 		if (orig_call) {
 			apdu = pri_call_apdu_find(orig_call, result->invoke_id);
 		}
@@ -4445,7 +4445,7 @@
 		if (!cc_record) {
 			break;
 		}
-		cc_record->signaling = PRI_MASTER(ctrl)->dummy_call;
+		cc_record->signaling = PRI_MASTER(ctrl)->link.dummy_call;
 		/*
 		 * Since we received this facility, we will not be allocating any
 		 * reference and linkage id's.

Modified: team/rmudgett/link_struct/pri_internal.h
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/link_struct/pri_internal.h?view=diff&rev=2049&r1=2048&r2=2049
==============================================================================
--- team/rmudgett/link_struct/pri_internal.h (original)
+++ team/rmudgett/link_struct/pri_internal.h Mon Oct 18 17:50:55 2010
@@ -66,6 +66,64 @@
 	unsigned length;
 	/*! Accumulated pri_message() contents. */
 	char str[2048];
+};
+
+/*! \brief Q.921 link controller structure */
+struct q921_link {
+	/*! Next Q.921 link in the chain. */
+	struct q921_link *next;/* BUGBUG list of links not supported yet. */
+	/*! D channel controller associated with this link. */
+	struct pri *ctrl;
+
+	/*!
+	 * \brief Q.931 Dummy call reference call associated with this TEI.
+	 * \note If present then this call is allocated as part of the
+	 * D channel control structure.
+	 */
+	struct q931_call *dummy_call;
+
+	/*! Q.921 Re-transmission queue */
+	struct q921_frame *tx_queue;
+
+	/*! Q.921 State */
+	enum q921_state state;
+
+	/*! Service Access Profile ID of this link */
+	int sapi;
+	/*! Terminal Endpoint ID of this link */
+	int tei;
+	/*! TEI assignment random indicator. */
+	int ri;
+
+	/*! V(A) - Next I-frame sequence number needing ack */
+	int v_a;
+	/*! V(S) - Next I-frame sequence number to send */
+	int v_s;
+	/*! V(R) - Next I-frame sequence number expected to receive */
+	int v_r;
+
+	/* Various timers */
+
+	/*! T-200 retransmission timer */
+	int t200_timer;
+	/*! Retry Count (T200) */
+	int RC;
+	int t202_timer;
+	int n202_counter;
+	/*! Max idle time */
+	int t203_timer;
+
+	/* MDL variables */
+	int mdl_timer;
+	int mdl_error;
+	enum q921_state mdl_error_state;
+	unsigned int mdl_free_me:1;
+
+	unsigned int peer_rx_busy:1;
+	unsigned int own_rx_busy:1;
+	unsigned int acknowledge_pending:1;
+	unsigned int reject_exception:1;
+	unsigned int l3_initiated:1;
 };
 
 /*! \brief D channel controller structure */
@@ -93,9 +151,8 @@
 	int localtype;		/* Local network type (unknown, network, cpe) */
 	int remotetype;		/* Remote network type (unknown, network, cpe) */
 
-	int sapi;
-	int tei;
-	int protodisc;
+	int protodisc;	/* Layer 3 protocol discriminator */
+
 	unsigned int nfas:1;/* TRUE if this D channel is involved with an NFAS group */
 	unsigned int bri:1;
 	unsigned int acceptinbanddisconnect:1;	/* Should we allow inband progress after DISCONNECT? */
@@ -112,57 +169,23 @@
 	unsigned int manual_connect_ack:1;/* TRUE if the CONNECT_ACKNOWLEDGE is sent with API call */
 	unsigned int mcid_support:1;/* TRUE if the upper layer supports MCID */
 
-	/* MDL variables */
-	int mdl_error;
-	int mdl_error_state;
-	int mdl_timer;
-	int mdl_free_me;
-
-	/* Q.921 State */
-	int q921_state;	
-	int RC;
-	int peer_rx_busy:1;
-	int own_rx_busy:1;
-	int acknowledge_pending:1;
-	int reject_exception:1;
-
-	int v_s;			/* Next N(S) for transmission */
-	int v_a;			/* Last acknowledged frame */
-	int v_r;			/* Next frame expected to be received */
+	/*! Layer 2 link control for D channel. */
+	struct q921_link link;
 	
 	int cref;			/* Next call reference value */
-	
-	int l3initiated;
-
-	/* Various timers */
-	int t203_timer;		/* Max idle time */
-	int t202_timer;
-	int n202_counter;
-	int ri;
-	int t200_timer;		/* T-200 retransmission timer */
+
 	/* All ISDN Timer values */
 	int timers[PRI_MAX_TIMERS];
 
 	/* Used by scheduler */
-	struct timeval tv;
 	int schedev;
 	pri_event ev;		/* Static event thingy */
 	/*! Subcommands for static event thingy. */
 	struct pri_subcommands subcmds;
 	
-	/* Q.921 Re-transmission queue */
-	struct q921_frame *txqueue;
-	
 	/* Q.931 calls */
-	q931_call **callpool;
-	q931_call *localpool;
-
-	/*!
-	 * \brief Q.931 Dummy call reference call associated with this TEI.
-	 * \note If present then this call is allocated as part of the
-	 * D channel control structure.
-	 */
-	q931_call *dummy_call;
+	struct q931_call **callpool;
+	struct q931_call *localpool;
 
 #ifdef LIBPRI_COUNTERS
 	/* q921/q931 packet counters */
@@ -592,7 +615,7 @@
 	int is_link_id_valid;
 
 	/* Bridged call info */
-	q931_call *bridged_call;        /* Pointer to other leg of bridged call (Used by Q.SIG when eliminating tromboned calls) */
+	struct q931_call *bridged_call;        /* Pointer to other leg of bridged call (Used by Q.SIG when eliminating tromboned calls) */
 
 	int changestatus;		/* SERVICE message changestatus */
 	int reversecharge;		/* Reverse charging indication:
@@ -1014,7 +1037,7 @@
 	/* Check master control structure */
 	my_ctrl = PRI_MASTER(my_ctrl);
 	return my_ctrl->bri && my_ctrl->localtype == PRI_NETWORK
-		&& my_ctrl->tei == Q921_TEI_GROUP;
+		&& my_ctrl->link.tei == Q921_TEI_GROUP;
 }
 
 /*!
@@ -1032,7 +1055,7 @@
 	/* Check master control structure */
 	my_ctrl = PRI_MASTER(my_ctrl);
 	return my_ctrl->bri && my_ctrl->localtype == PRI_CPE
-		&& my_ctrl->tei == Q921_TEI_GROUP;
+		&& my_ctrl->link.tei == Q921_TEI_GROUP;
 }
 
 /*!
@@ -1083,7 +1106,7 @@
 
 	/* Check master control structure */
 	my_ctrl = PRI_MASTER(my_ctrl);
-	return my_ctrl->tei == Q921_TEI_PRI;
+	return my_ctrl->link.tei == Q921_TEI_PRI;
 }
 
 /*!
@@ -1100,7 +1123,7 @@
 
 	/* Check master control structure */
 	my_ctrl = PRI_MASTER(my_ctrl);
-	return my_ctrl->tei == Q921_TEI_GROUP;
+	return my_ctrl->link.tei == Q921_TEI_GROUP;
 }
 
 #define Q931_DUMMY_CALL_REFERENCE	-1
@@ -1112,7 +1135,7 @@
  * \retval TRUE if given call is a dummy call.
  * \retval FALSE otherwise.
  */
-static inline int q931_is_dummy_call(const q931_call *call)
+static inline int q931_is_dummy_call(const struct q931_call *call)
 {
 	return (call->cr == Q931_DUMMY_CALL_REFERENCE) ? 1 : 0;
 }

Modified: team/rmudgett/link_struct/q921.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/link_struct/q921.c?view=diff&rev=2049&r1=2048&r2=2049
==============================================================================
--- team/rmudgett/link_struct/q921.c (original)
+++ team/rmudgett/link_struct/q921.c Mon Oct 18 17:50:55 2010
@@ -47,10 +47,10 @@
 
 #define Q921_INIT(link, hf) do { \
 	memset(&(hf),0,sizeof(hf)); \
-	(hf).h.sapi = (link)->sapi; \
+	(hf).h.sapi = (link)->link.sapi; \
 	(hf).h.ea1 = 0; \
 	(hf).h.ea2 = 1; \
-	(hf).h.tei = (link)->tei; \
+	(hf).h.tei = (link)->link.tei; \
 } while(0)
 
 static void q921_dump_pri(struct pri *link, char direction_tag);
@@ -104,14 +104,14 @@
 		 * Q921 keeps flipping back and forth between these two states
 		 * when it has nothing better to do.
 		 */
-		switch (link->q921_state) {
+		switch (link->link.state) {
 		case Q921_MULTI_FRAME_ESTABLISHED:
 		case Q921_TIMER_RECOVERY:
 			switch (newstate) {
 			case Q921_MULTI_FRAME_ESTABLISHED:
 			case Q921_TIMER_RECOVERY:
 				/* Suppress displaying this state transition. */
-				link->q921_state = newstate;
+				link->link.state = newstate;
 				return;
 			default:
 				break;
@@ -120,27 +120,27 @@
 		default:
 			break;
 		}
-		if (link->q921_state != newstate) {
+		if (link->link.state != newstate) {
 			pri_message(ctrl, "Changing from state %d(%s) to %d(%s)\n",
-				link->q921_state, q921_state2str(link->q921_state),
+				link->link.state, q921_state2str(link->link.state),
 				newstate, q921_state2str(newstate));
 		}
 	}
-	link->q921_state = newstate;
+	link->link.state = newstate;
 }
 
 static void q921_discard_iqueue(struct pri *link)
 {
 	struct q921_frame *f, *p;
 
-	f = link->txqueue;
+	f = link->link.tx_queue;
 	while (f) {
 		p = f;
 		f = f->next;
 		/* Free frame */
 		free(p);
 	}
-	link->txqueue = NULL;
+	link->link.tx_queue = NULL;
 }
 
 static int q921_transmit(struct pri *ctrl, q921_h *h, int len) 
@@ -201,21 +201,21 @@
 	ctrl = PRI_MASTER(link);
 
 	/* Start the TEI request timer. */
-	pri_schedule_del(ctrl, link->t202_timer);
-	link->t202_timer =
+	pri_schedule_del(ctrl, link->link.t202_timer);
+	link->link.t202_timer =
 		pri_schedule_event(ctrl, ctrl->timers[PRI_TIMER_T202], t202_expire, link);
 
-	++link->n202_counter;
-	if (!link->t202_timer || link->n202_counter > ctrl->timers[PRI_TIMER_N202]) {
-		if (!link->t202_timer) {
+	++link->link.n202_counter;
+	if (!link->link.t202_timer || link->link.n202_counter > ctrl->timers[PRI_TIMER_N202]) {
+		if (!link->link.t202_timer) {
 			pri_error(ctrl, "Could not start T202 timer.");
 		} else {
-			pri_schedule_del(ctrl, link->t202_timer);
-			link->t202_timer = 0;
+			pri_schedule_del(ctrl, link->link.t202_timer);
+			link->link.t202_timer = 0;
 		}
 		pri_error(ctrl, "Unable to receive TEI from network in state %d(%s)!\n",
-			link->q921_state, q921_state2str(link->q921_state));
-		switch (link->q921_state) {
+			link->link.state, q921_state2str(link->link.state));
+		switch (link->link.state) {
 		case Q921_ASSIGN_AWAITING_TEI:
 			break;
 		case Q921_ESTABLISH_AWAITING_TEI:
@@ -231,13 +231,13 @@
 	}
 
 	/* Send TEI request */
-	link->ri = random() % 65535;
-	q921_send_tei(ctrl, Q921_TEI_IDENTITY_REQUEST, link->ri, Q921_TEI_GROUP, 1);
+	link->link.ri = random() % 65535;
+	q921_send_tei(ctrl, Q921_TEI_IDENTITY_REQUEST, link->link.ri, Q921_TEI_GROUP, 1);
 }
 
 static void q921_tei_request(struct pri *link)
 {
-	link->n202_counter = 0;
+	link->link.n202_counter = 0;
 	t202_expire(link);
 }
 
@@ -265,7 +265,7 @@
 		return;
 	}
 	if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
-		pri_message(ctrl, "TEI=%d Sending DM\n", link->tei);
+		pri_message(ctrl, "TEI=%d Sending DM\n", link->link.tei);
 	}
 	q921_transmit(ctrl, &h, 4);
 }
@@ -294,7 +294,7 @@
 		return;
 	}
 	if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
-		pri_message(ctrl, "TEI=%d Sending DISC\n", link->tei);
+		pri_message(ctrl, "TEI=%d Sending DISC\n", link->link.tei);
 	}
 	q921_transmit(ctrl, &h, 4);
 }
@@ -323,7 +323,7 @@
 		return;
 	}
 	if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
-		pri_message(ctrl, "TEI=%d Sending UA\n", link->tei);
+		pri_message(ctrl, "TEI=%d Sending UA\n", link->link.tei);
 	}
 	q921_transmit(ctrl, &h, 3);
 }
@@ -352,7 +352,7 @@
 		return;
 	}
 	if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
-		pri_message(ctrl, "TEI=%d Sending SABME\n", link->tei);
+		pri_message(ctrl, "TEI=%d Sending SABME\n", link->link.tei);
 	}
 	q921_transmit(ctrl, &h, 3);
 }
@@ -365,7 +365,7 @@
 
 	ctrl = PRI_MASTER(link);
 
-	for (prev = NULL, f = link->txqueue; f; prev = f, f = f->next) {
+	for (prev = NULL, f = link->link.tx_queue; f; prev = f, f = f->next) {
 		if (!f->transmitted) {
 			break;
 		}
@@ -375,14 +375,14 @@
 			if (prev)
 				prev->next = f->next;
 			else
-				link->txqueue = f->next;
+				link->link.tx_queue = f->next;
 			if (ctrl->debug & PRI_DEBUG_Q921_DUMP) {
 				pri_message(ctrl,
-					"-- ACKing N(S)=%d, txqueue head is N(S)=%d (-1 is empty, -2 is not transmitted)\n",
+					"-- ACKing N(S)=%d, tx_queue head is N(S)=%d (-1 is empty, -2 is not transmitted)\n",
 					f->h.n_s,
-					link->txqueue
-						? link->txqueue->transmitted
-							? link->txqueue->h.n_s
+					link->link.tx_queue
+						? link->link.tx_queue->transmitted
+							? link->link.tx_queue->h.n_s
 							: -2
 						: -1);
 			}
@@ -406,8 +406,8 @@
 
 	if (ctrl->debug & PRI_DEBUG_Q921_DUMP)
 		pri_message(ctrl, "-- Restarting T200 timer\n");
-	pri_schedule_del(ctrl, link->t200_timer);
-	link->t200_timer = pri_schedule_event(ctrl, ctrl->timers[PRI_TIMER_T200], t200_expire, link);
+	pri_schedule_del(ctrl, link->link.t200_timer);
+	link->link.t200_timer = pri_schedule_event(ctrl, ctrl->timers[PRI_TIMER_T200], t200_expire, link);
 }
 
 #if 0
@@ -419,15 +419,15 @@
 
 	if (ctrl->debug & PRI_DEBUG_Q921_DUMP)
 		pri_message(ctrl, "-- Restarting T203 timer\n");
-	pri_schedule_del(ctrl, link->t203_timer);
-	link->t203_timer = pri_schedule_event(ctrl, ctrl->timers[PRI_TIMER_T203], t203_expire, link);
+	pri_schedule_del(ctrl, link->link.t203_timer);
+	link->link.t203_timer = pri_schedule_event(ctrl, ctrl->timers[PRI_TIMER_T203], t203_expire, link);
 }
 #endif
 
 #if 0
 static int q921_unacked_iframes(struct pri *link)
 {
-	struct q921_frame *f = link->txqueue;
+	struct q921_frame *f = link->link.tx_queue;
 	int cnt = 0;
 
 	while(f) {
@@ -446,14 +446,14 @@
 
 	ctrl = PRI_MASTER(link);
 
-	if (link->t203_timer) {
+	if (link->link.t203_timer) {
 		if (ctrl->debug & PRI_DEBUG_Q921_DUMP)
 			pri_message(ctrl, "T203 requested to start without stopping first\n");
-		pri_schedule_del(ctrl, link->t203_timer);
+		pri_schedule_del(ctrl, link->link.t203_timer);
 	}
 	if (ctrl->debug & PRI_DEBUG_Q921_DUMP)
 		pri_message(ctrl, "-- Starting T203 timer\n");
-	link->t203_timer = pri_schedule_event(ctrl, ctrl->timers[PRI_TIMER_T203], t203_expire, link);
+	link->link.t203_timer = pri_schedule_event(ctrl, ctrl->timers[PRI_TIMER_T203], t203_expire, link);
 }
 
 static void stop_t203(struct pri *link)
@@ -462,11 +462,11 @@
 
 	ctrl = PRI_MASTER(link);
 
-	if (link->t203_timer) {
+	if (link->link.t203_timer) {
 		if (ctrl->debug & PRI_DEBUG_Q921_DUMP)
 			pri_message(ctrl, "-- Stopping T203 timer\n");
-		pri_schedule_del(ctrl, link->t203_timer);
-		link->t203_timer = 0;
+		pri_schedule_del(ctrl, link->link.t203_timer);
+		link->link.t203_timer = 0;
 	} else {
 		if (ctrl->debug & PRI_DEBUG_Q921_DUMP)
 			pri_message(ctrl, "-- T203 requested to stop when not started\n");
@@ -479,14 +479,14 @@
 
 	ctrl = PRI_MASTER(link);
 
-	if (link->t200_timer) {
+	if (link->link.t200_timer) {
 		if (ctrl->debug & PRI_DEBUG_Q921_DUMP)
 			pri_message(ctrl, "T200 requested to start without stopping first\n");
-		pri_schedule_del(ctrl, link->t200_timer);
+		pri_schedule_del(ctrl, link->link.t200_timer);
 	}
 	if (ctrl->debug & PRI_DEBUG_Q921_DUMP)
 		pri_message(ctrl, "-- Starting T200 timer\n");
-	link->t200_timer = pri_schedule_event(ctrl, ctrl->timers[PRI_TIMER_T200], t200_expire, link);
+	link->link.t200_timer = pri_schedule_event(ctrl, ctrl->timers[PRI_TIMER_T200], t200_expire, link);
 }
 
 static void stop_t200(struct pri *link)
@@ -495,11 +495,11 @@
 
 	ctrl = PRI_MASTER(link);
 
-	if (link->t200_timer) {
+	if (link->link.t200_timer) {
 		if (ctrl->debug & PRI_DEBUG_Q921_DUMP)
 			pri_message(ctrl, "-- Stopping T200 timer\n");
-		pri_schedule_del(ctrl, link->t200_timer);
-		link->t200_timer = 0;
+		pri_schedule_del(ctrl, link->link.t200_timer);
+		link->link.t200_timer = 0;
 	} else {
 		if (ctrl->debug & PRI_DEBUG_Q921_DUMP)
 			pri_message(ctrl, "-- T200 requested to stop when not started\n");
@@ -515,7 +515,7 @@
 
 	ctrl = PRI_MASTER(link);
 
-	for (f = link->txqueue; f; f = f->next) {
+	for (f = link->link.tx_queue; f; f = f->next) {
 		if (!f->transmitted) {
 			/* This frame has not been sent yet. */
 			break;
@@ -526,20 +526,20 @@
 		return 0;
 	}
 
-	if (link->peer_rx_busy
-		|| (link->v_s == Q921_ADD(link->v_a, ctrl->timers[PRI_TIMER_K]))) {
+	if (link->link.peer_rx_busy
+		|| (link->link.v_s == Q921_ADD(link->link.v_a, ctrl->timers[PRI_TIMER_K]))) {
 		/* Don't flood debug trace if not really looking at Q.921 layer. */
 		if (ctrl->debug & (/* PRI_DEBUG_Q921_STATE | */ PRI_DEBUG_Q921_DUMP)) {
 			pri_message(ctrl,
 				"TEI=%d Couldn't transmit I-frame at this time due to peer busy condition or window shut\n",
-				link->tei);
+				link->link.tei);
 		}
 		return 0;
 	}
 
 	/* Send all pending frames that fit in the window. */
 	for (; f; f = f->next) {
-		if (link->v_s == Q921_ADD(link->v_a, ctrl->timers[PRI_TIMER_K])) {
+		if (link->link.v_s == Q921_ADD(link->link.v_a, ctrl->timers[PRI_TIMER_K])) {
 			/* The window is no longer open. */
 			break;
 		}
@@ -552,19 +552,19 @@
 		 * Done now because the frame may have been queued before we
 		 * had an assigned TEI.
 		 */
-		f->h.h.tei = link->tei;
-
-		f->h.n_s = link->v_s;
-		f->h.n_r = link->v_r;
+		f->h.h.tei = link->link.tei;
+
+		f->h.n_s = link->link.v_s;
+		f->h.n_r = link->link.v_r;
 		f->h.ft = 0;
 		f->h.p_f = 0;
 		if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
 			pri_message(ctrl,
 				"TEI=%d Transmitting N(S)=%d, window is open V(A)=%d K=%d\n",
-				link->tei, f->h.n_s, link->v_a, ctrl->timers[PRI_TIMER_K]);
+				link->link.tei, f->h.n_s, link->link.v_a, ctrl->timers[PRI_TIMER_K]);
 		}
 		q921_transmit(ctrl, (q921_h *) (&f->h), f->len);
-		Q921_INC(link->v_s);
+		Q921_INC(link->link.v_s);
 		++frames_txd;
 
 		if (ctrl->debug & PRI_DEBUG_Q931_DUMP) {
@@ -576,13 +576,13 @@
 			 * Also the dump is done here so the Q.931 part is decoded only
 			 * once instead of for every retransmission.
 			 */
-			q931_dump(ctrl, link->tei, (q931_h *) f->h.data, f->len - 4, 1);
+			q931_dump(ctrl, link->link.tei, (q931_h *) f->h.data, f->len - 4, 1);
 		}
 	}
 
 	if (frames_txd) {
-		link->acknowledge_pending = 0;
-		if (!link->t200_timer) {
+		link->link.acknowledge_pending = 0;
+		if (!link->link.t200_timer) {
 			stop_t203(link);
 			start_t200(link);
 		}
@@ -602,7 +602,7 @@
 	h.s.x0 = 0;	/* Always 0 */
 	h.s.ss = 2;	/* Reject */
 	h.s.ft = 1;	/* Frametype (01) */
-	h.s.n_r = link->v_r;	/* Where to start retransmission N(R) */
+	h.s.n_r = link->link.v_r;	/* Where to start retransmission N(R) */
 	h.s.p_f = pf;	
 	switch(ctrl->localtype) {
 	case PRI_NETWORK:
@@ -616,7 +616,7 @@
 		return;
 	}
 	if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
-		pri_message(ctrl, "TEI=%d Sending REJ N(R)=%d\n", link->tei, link->v_r);
+		pri_message(ctrl, "TEI=%d Sending REJ N(R)=%d\n", link->link.tei, link->link.v_r);
 	}
 	q921_transmit(ctrl, &h, 4);
 }
@@ -632,7 +632,7 @@
 	h.s.x0 = 0;	/* Always 0 */
 	h.s.ss = 0; /* Receive Ready */
 	h.s.ft = 1;	/* Frametype (01) */
-	h.s.n_r = link->v_r;	/* N(R) */
+	h.s.n_r = link->link.v_r;	/* N(R) */
 	h.s.p_f = pbit;		/* Poll/Final set appropriately */
 	switch(ctrl->localtype) {
 	case PRI_NETWORK:
@@ -653,7 +653,7 @@
 	}
 #if 0	/* Don't flood debug trace with RR if not really looking at Q.921 layer. */
 	if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
-		pri_message(ctrl, "TEI=%d Sending RR N(R)=%d\n", link->tei, link->v_r);
+		pri_message(ctrl, "TEI=%d Sending RR N(R)=%d\n", link->link.tei, link->link.v_r);
 	}
 #endif
 	q921_transmit(ctrl, &h, 4);
@@ -661,9 +661,9 @@
 
 static void transmit_enquiry(struct pri *link)
 {
-	if (!link->own_rx_busy) {
+	if (!link->link.own_rx_busy) {
 		q921_rr(link, 1, 1);
-		link->acknowledge_pending = 0;
+		link->link.acknowledge_pending = 0;
 		start_t200(link);
 	} else {
 		/* XXX: Implement me... */
@@ -682,20 +682,20 @@
 		q921_dump_pri(link, ' ');
 	}
 
-	link->t200_timer = 0;
-
-	switch (link->q921_state) {
+	link->link.t200_timer = 0;
+
+	switch (link->link.state) {
 	case Q921_MULTI_FRAME_ESTABLISHED:
-		link->RC = 0;
+		link->link.RC = 0;
 		transmit_enquiry(link);
-		link->RC++;
+		link->link.RC++;
 		q921_setstate(link, Q921_TIMER_RECOVERY);
 		break;
 	case Q921_TIMER_RECOVERY:
 		/* SDL Flow Figure B.8/Q.921 Page 81 */
-		if (link->RC != ctrl->timers[PRI_TIMER_N200]) {
+		if (link->link.RC != ctrl->timers[PRI_TIMER_N200]) {
 #if 0
-			if (link->v_s == link->v_a) {
+			if (link->link.v_s == link->link.v_a) {
 				transmit_enquiry(link);
 			}
 #else
@@ -703,17 +703,17 @@
 			 * side, instead of retransmission of the last I-frame we sent */
 			transmit_enquiry(link);
 #endif
-			link->RC++;
+			link->link.RC++;
 		} else {
 			q921_mdl_error(link, 'I');
 			q921_establish_data_link(link);
-			link->l3initiated = 0;
+			link->link.l3_initiated = 0;
 			q921_setstate(link, Q921_AWAITING_ESTABLISHMENT);
 		}
 		break;
 	case Q921_AWAITING_ESTABLISHMENT:
-		if (link->RC != ctrl->timers[PRI_TIMER_N200]) {
-			link->RC++;
+		if (link->link.RC != ctrl->timers[PRI_TIMER_N200]) {
+			link->link.RC++;
 			q921_send_sabme(link);
 			start_t200(link);
 		} else {
@@ -725,8 +725,8 @@
 		}
 		break;
 	case Q921_AWAITING_RELEASE:
-		if (link->RC != ctrl->timers[PRI_TIMER_N200]) {
-			++link->RC;
+		if (link->link.RC != ctrl->timers[PRI_TIMER_N200]) {
+			++link->link.RC;
 			q921_send_disc(link, 1);
 			start_t200(link);
 		} else {
@@ -739,7 +739,7 @@
 	default:
 		/* Looks like someone forgot to stop the T200 timer. */
 		pri_error(ctrl, "T200 expired in state %d(%s)\n",
-			link->q921_state, q921_state2str(link->q921_state));
+			link->link.state, q921_state2str(link->link.state));
 		break;
 	}
 }
@@ -762,7 +762,7 @@
 	h->h.sapi = 0;
 	h->h.ea1 = 0;
 	h->h.ea2 = 1;
-	h->h.tei = link->tei;
+	h->h.tei = link->link.tei;
 	h->u.m3 = 0;
 	h->u.m2 = 0;
 	h->u.p_f = 0;	/* Poll bit set */
@@ -790,7 +790,7 @@
 static struct pri *pri_find_tei(struct pri *ctrl, int sapi, int tei)
 {
 	for (; ctrl; ctrl = ctrl->subchannel) {
-		if (ctrl->tei == tei && ctrl->sapi == sapi)
+		if (ctrl->link.tei == tei && ctrl->link.sapi == sapi)
 			return ctrl;
 	}
 
@@ -806,12 +806,12 @@
 	ctrl = PRI_MASTER(link);
 
 	if (PTMP_MODE(ctrl)) {
-		if (link->tei == Q921_TEI_GROUP) {
+		if (link->link.tei == Q921_TEI_GROUP) {
 			pri_error(ctrl, "Huh?! For PTMP, we shouldn't be sending I-frames out the group TEI\n");
 			return 0;
 		}
 		if (BRI_TE_PTMP(ctrl)) {
-			switch (link->q921_state) {
+			switch (link->link.state) {
 			case Q921_TEI_UNASSIGNED:
 				q921_setstate(link, Q921_ESTABLISH_AWAITING_TEI);
 				q921_tei_request(link);
@@ -828,11 +828,11 @@
 	}
 
 	/* Figure B.7/Q.921 Page 70 */
-	switch (link->q921_state) {
+	switch (link->link.state) {
 	case Q921_TEI_ASSIGNED:
 		/* If we aren't in a state compatiable with DL-DATA requests, start getting us there here */
 		q921_establish_data_link(link);
-		link->l3initiated = 1;
+		link->link.l3_initiated = 1;
 		q921_setstate(link, Q921_AWAITING_ESTABLISHMENT);
 		/* For all rest, we've done the work to get us up prior to this and fall through */
 	case Q921_ESTABLISH_AWAITING_TEI:
@@ -840,7 +840,7 @@
 	case Q921_AWAITING_ESTABLISHMENT:
 	case Q921_MULTI_FRAME_ESTABLISHED:
 		/* Find queue tail. */
-		for (f = link->txqueue; f; f = f->next) {
+		for (f = link->link.tx_queue; f; f = f->next) {
 			prev = f;
 		}
 
@@ -870,23 +870,23 @@
 			if (prev)
 				prev->next = f;
 			else
-				link->txqueue = f;
-
-			if (link->q921_state != Q921_MULTI_FRAME_ESTABLISHED) {
+				link->link.tx_queue = f;
+
+			if (link->link.state != Q921_MULTI_FRAME_ESTABLISHED) {
 				if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
 					pri_message(ctrl,
 						"TEI=%d Just queued I-frame since in state %d(%s)\n",
-						link->tei,
-						link->q921_state, q921_state2str(link->q921_state));
+						link->link.tei,
+						link->link.state, q921_state2str(link->link.state));
 				}
 				break;
 			}
 
-			if (link->peer_rx_busy || (link->v_s == Q921_ADD(link->v_a, ctrl->timers[PRI_TIMER_K]))) {
+			if (link->link.peer_rx_busy || (link->link.v_s == Q921_ADD(link->link.v_a, ctrl->timers[PRI_TIMER_K]))) {
 				if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
 					pri_message(ctrl,
 						"TEI=%d Just queued I-frame due to peer busy condition or window shut\n",
-						link->tei);
+						link->link.tei);
 				}
 				break;
 			}
@@ -902,7 +902,7 @@
 	case Q921_AWAITING_RELEASE:
 	default:
 		pri_error(ctrl, "Cannot transmit frames in state %d(%s)\n",
-			link->q921_state, q921_state2str(link->q921_state));
+			link->link.state, q921_state2str(link->link.state));
 		break;
 	}
 	return 0;
@@ -918,18 +918,18 @@
 	if (ctrl->debug & PRI_DEBUG_Q921_DUMP)
 		pri_message(ctrl, "%s\n", __FUNCTION__);
 
-	link->t203_timer = 0;
-
-	switch (link->q921_state) {
+	link->link.t203_timer = 0;
+
+	switch (link->link.state) {
 	case Q921_MULTI_FRAME_ESTABLISHED:
 		transmit_enquiry(link);
-		link->RC = 0;
+		link->link.RC = 0;
 		q921_setstate(link, Q921_TIMER_RECOVERY);
 		break;
 	default:
 		/* Looks like someone forgot to stop the T203 timer. */
 		pri_error(ctrl, "T203 expired in state %d(%s)\n",
-			link->q921_state, q921_state2str(link->q921_state));
+			link->link.state, q921_state2str(link->link.state));
 		break;
 	}
 }
@@ -944,7 +944,7 @@
 
 	unacked = pending = 0;
 
-	for (f = link->txqueue; f; f = f->next) {
+	for (f = link->link.tx_queue; f; f = f->next) {
 		if (f->transmitted) {
 			unacked++;
 		} else {
@@ -1138,14 +1138,14 @@
 	ctrl = PRI_MASTER(link);
 
 	pri_message(ctrl, "%c TEI: %d State %d(%s)\n",
-		direction_tag, link->tei, link->q921_state, q921_state2str(link->q921_state));
+		direction_tag, link->link.tei, link->link.state, q921_state2str(link->link.state));
 	pri_message(ctrl, "%c V(A)=%d, V(S)=%d, V(R)=%d\n",
-		direction_tag, link->v_a, link->v_s, link->v_r);
-	pri_message(ctrl, "%c K=%d, RC=%d, l3initiated=%d, reject_except=%d, ack_pend=%d\n",
-		direction_tag, ctrl->timers[PRI_TIMER_K], link->RC, link->l3initiated,
-		link->reject_exception, link->acknowledge_pending);
+		direction_tag, link->link.v_a, link->link.v_s, link->link.v_r);
+	pri_message(ctrl, "%c K=%d, RC=%d, l3_initiated=%d, reject_except=%d, ack_pend=%d\n",
+		direction_tag, ctrl->timers[PRI_TIMER_K], link->link.RC, link->link.l3_initiated,
+		link->link.reject_exception, link->link.acknowledge_pending);
 	pri_message(ctrl, "%c T200_id=%d, N200=%d, T203_id=%d\n",
-		direction_tag, link->t200_timer, ctrl->timers[PRI_TIMER_N200], link->t203_timer);
+		direction_tag, link->link.t200_timer, ctrl->timers[PRI_TIMER_N200], link->link.t203_timer);
 }
 
 static void q921_dump_pri_by_h(struct pri *ctrl, char direction_tag, q921_h *h)
@@ -1214,7 +1214,7 @@
 		tei = 64;
 		do {
 			for (sub = ctrl; sub->subchannel; sub = sub->subchannel) {
-				if (sub->subchannel->tei == tei) {
+				if (sub->subchannel->link.tei == tei) {
 					/* This TEI is already assigned, try next one. */
 					++tei;
 					if (tei < Q921_TEI_GROUP) {
@@ -1245,7 +1245,7 @@
 		/* Assuming we're operating on the sub here */
 		link = ctrl->subchannel;
 		
-		switch (link->q921_state) {
+		switch (link->link.state) {
 		case Q921_ASSIGN_AWAITING_TEI:
 		case Q921_ESTABLISH_AWAITING_TEI:
 			break;
@@ -1254,22 +1254,22 @@
 			return NULL;
 		}
 
-		if (ri != link->ri) {
+		if (ri != link->link.ri) {
 			pri_message(ctrl,
 				"TEI assignment received for another Ri %02x (ours is %02x)\n",
-				ri, link->ri);
+				ri, link->link.ri);
 			return NULL;
 		}
 
-		pri_schedule_del(ctrl, link->t202_timer);
-		link->t202_timer = 0;
-
-		link->tei = tei;
+		pri_schedule_del(ctrl, link->link.t202_timer);
+		link->link.t202_timer = 0;
+
+		link->link.tei = tei;
 		if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
 			pri_message(ctrl, "Got assigned TEI %d\n", tei);
 		}
 
-		switch (link->q921_state) {
+		switch (link->link.state) {
 		case Q921_ASSIGN_AWAITING_TEI:
 			q921_setstate(link, Q921_TEI_ASSIGNED);
 			ctrl->ev.gen.e = PRI_EVENT_DCHAN_UP;
@@ -1277,7 +1277,7 @@
 			break;
 		case Q921_ESTABLISH_AWAITING_TEI:
 			q921_establish_data_link(link);
-			link->l3initiated = 1;
+			link->link.l3_initiated = 1;
 			q921_setstate(link, Q921_AWAITING_ESTABLISHMENT);
 			ctrl->ev.gen.e = PRI_EVENT_DCHAN_UP;
 			res = &ctrl->ev;
@@ -1293,14 +1293,14 @@
 		/* Assuming we're operating on the sub here */
 		link = ctrl->subchannel;
 
-		if (link->q921_state < Q921_TEI_ASSIGNED) {
+		if (link->link.state < Q921_TEI_ASSIGNED) {
 			/* We do not have a TEI. */
 			return NULL;
 		}
 
 		/* If it's addressed to the group TEI or to our TEI specifically, we respond */
-		if (tei == Q921_TEI_GROUP || tei == link->tei) {
-			q921_send_tei(ctrl, Q921_TEI_IDENTITY_CHECK_RESPONSE, random() % 65535, link->tei, 1);
+		if (tei == Q921_TEI_GROUP || tei == link->link.tei) {
+			q921_send_tei(ctrl, Q921_TEI_IDENTITY_CHECK_RESPONSE, random() % 65535, link->link.tei, 1);
 		}
 		break;
 	case Q921_TEI_IDENTITY_REMOVE:
@@ -1310,13 +1310,13 @@
 		/* Assuming we're operating on the sub here */
 		link = ctrl->subchannel;
 
-		if (link->q921_state < Q921_TEI_ASSIGNED) {
+		if (link->link.state < Q921_TEI_ASSIGNED) {
 			/* We do not have a TEI. */
 			return NULL;
 		}
 
 		/* If it's addressed to the group TEI or to our TEI specifically, we respond */
-		if (tei == Q921_TEI_GROUP || tei == link->tei) {
+		if (tei == Q921_TEI_GROUP || tei == link->link.tei) {
 			q921_mdl_remove(link);
 			q921_start(link);
 		}
@@ -1339,10 +1339,10 @@
 
 static void q921_clear_exception_conditions(struct pri *link)
 {
-	link->own_rx_busy = 0;
-	link->peer_rx_busy = 0;
-	link->reject_exception = 0;
-	link->acknowledge_pending = 0;
+	link->link.own_rx_busy = 0;
+	link->link.peer_rx_busy = 0;
+	link->link.reject_exception = 0;
+	link->link.acknowledge_pending = 0;
 }
 
 static pri_event *q921_sabme_rx(struct pri *link, q921_h *h)
@@ -1353,7 +1353,7 @@
 
 	ctrl = PRI_MASTER(link);
 
-	switch (link->q921_state) {
+	switch (link->link.state) {
 	case Q921_TIMER_RECOVERY:
 		/* Timer recovery state handling is same as multiframe established */
 	case Q921_MULTI_FRAME_ESTABLISHED:
@@ -1361,7 +1361,7 @@
 		q921_send_ua(link, h->u.p_f);
 		q921_clear_exception_conditions(link);
 		q921_mdl_error(link, 'F');
-		if (link->v_s != link->v_a) {
+		if (link->link.v_s != link->link.v_a) {
 			q921_discard_iqueue(link);
 			/* DL-ESTABLISH indication */
 			delay_q931_dl_event = Q931_DL_EVENT_DL_ESTABLISH_IND;
@@ -1370,7 +1370,7 @@
 		}
 		stop_t200(link);
 		start_t203(link);
-		link->v_s = link->v_a = link->v_r = 0;
+		link->link.v_s = link->link.v_a = link->link.v_r = 0;
 		q921_setstate(link, Q921_MULTI_FRAME_ESTABLISHED);
 		if (delay_q931_dl_event != Q931_DL_EVENT_NONE) {
 			/* Delayed because Q.931 could send STATUS messages. */
@@ -1380,7 +1380,7 @@
 	case Q921_TEI_ASSIGNED:
 		q921_send_ua(link, h->u.p_f);
 		q921_clear_exception_conditions(link);
-		link->v_s = link->v_a = link->v_r = 0;
+		link->link.v_s = link->link.v_a = link->link.v_r = 0;
 		/* DL-ESTABLISH indication */
 		delay_q931_dl_event = Q931_DL_EVENT_DL_ESTABLISH_IND;
 		if (PTP_MODE(ctrl)) {
@@ -1402,7 +1402,7 @@
 		break;
 	default:
 		pri_error(ctrl, "Cannot handle SABME in state %d(%s)\n",
-			link->q921_state, q921_state2str(link->q921_state));
+			link->link.state, q921_state2str(link->link.state));
 		break;
 	}
 
@@ -1417,10 +1417,10 @@
 	ctrl = PRI_MASTER(link);
 
 	if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
-		pri_message(ctrl, "TEI=%d Got DISC\n", link->tei);
-	}
-
-	switch (link->q921_state) {
+		pri_message(ctrl, "TEI=%d Got DISC\n", link->link.tei);
+	}
+
+	switch (link->link.state) {
 	case Q921_TEI_ASSIGNED:
 	case Q921_AWAITING_ESTABLISHMENT:
 		q921_send_dm(link, h->u.p_f);
@@ -1435,14 +1435,14 @@
 		/* DL-RELEASE indication */
 		q931_dl_event(link, Q931_DL_EVENT_DL_RELEASE_IND);
 		stop_t200(link);
-		if (link->q921_state == Q921_MULTI_FRAME_ESTABLISHED)
+		if (link->link.state == Q921_MULTI_FRAME_ESTABLISHED)
 			stop_t203(link);
 		q921_setstate(link, Q921_TEI_ASSIGNED);
 		q921_restart_ptp_link_if_needed(link);
 		break;
 	default:
 		pri_error(ctrl, "Don't know what to do with DISC in state %d(%s)\n",
-			link->q921_state, q921_state2str(link->q921_state));
+			link->link.state, q921_state2str(link->link.state));
 		break;
 	}
 
@@ -1457,7 +1457,7 @@
 	ctrl = PRI_MASTER(link);
 
 	if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
-		pri_message(ctrl, "MDL-REMOVE: Removing TEI %d\n", link->tei);
+		pri_message(ctrl, "MDL-REMOVE: Removing TEI %d\n", link->link.tei);
 	}
 	if (BRI_NT_PTMP(ctrl)) {
 		if (link == ctrl) {
@@ -1469,7 +1469,7 @@
 		mdl_free_me = 0;
 	}
 
-	switch (link->q921_state) {
+	switch (link->link.state) {
 	case Q921_TEI_ASSIGNED:
 		/* XXX: deviation! Since we don't have a UI queue, we just discard our I-queue */
 		q921_discard_iqueue(link);
@@ -1506,7 +1506,7 @@
 		break;
 	default:
 		pri_error(ctrl, "MDL-REMOVE when in state %d(%s)\n",
-			link->q921_state, q921_state2str(link->q921_state));
+			link->link.state, q921_state2str(link->link.state));
 		return;
 	}
 
@@ -1516,9 +1516,9 @@
 	 * Negate the TEI value so debug messages will display a
 	 * negated TEI when it is actually unassigned.
 	 */
-	link->tei = -link->tei;
-
-	link->mdl_free_me = mdl_free_me;
+	link->link.tei = -link->link.tei;
+
+	link->link.mdl_free_me = mdl_free_me;
 }
 
 static int q921_mdl_handle_network_error(struct pri *link, char error)
@@ -1600,7 +1600,7 @@
 		q921_discard_iqueue(link);
 		q921_establish_data_link(link);
 		q921_setstate(link, Q921_AWAITING_ESTABLISHMENT);
-		link->l3initiated = 1;
+		link->link.l3_initiated = 1;
 
 		ctrl->schedev = 1;
 		ctrl->ev.gen.e = PRI_EVENT_DCHAN_DOWN;
@@ -1657,12 +1657,12 @@
 {
 	struct pri *link = vlink;
 
-	q921_mdl_handle_error(link, link->mdl_error, link->mdl_error_state);
-
-	link->mdl_error = 0;
-	link->mdl_timer = 0;
-
-	if (link->mdl_free_me) {
+	q921_mdl_handle_error(link, link->link.mdl_error, link->link.mdl_error_state);
+
+	link->link.mdl_error = 0;
+	link->link.mdl_timer = 0;
+
+	if (link->link.mdl_free_me) {
 		struct pri *ctrl;
 		struct pri *freep = NULL, *prev, *cur;
 
@@ -1681,12 +1681,12 @@
 		}
 
 		if (freep == NULL) {
-			pri_error(ctrl, "Huh!? no match found in list for TEI %d\n", -link->tei);
+			pri_error(ctrl, "Huh!? no match found in list for TEI %d\n", -link->link.tei);
 			return;
 		}
 
 		if (ctrl->debug & PRI_DEBUG_Q921_STATE) {
-			pri_message(ctrl, "Freeing TEI of %d\n", -freep->tei);
+			pri_message(ctrl, "Freeing TEI of %d\n", -freep->link.tei);
 		}
 
 		__pri_free_tei(freep);
@@ -1706,20 +1706,20 @@
 	case 'A':
 		pri_message(ctrl,
 			"TEI=%d MDL-ERROR (A): Got supervisory frame with F=1 in state %d(%s)\n",
-			link->tei, link->q921_state, q921_state2str(link->q921_state));
+			link->link.tei, link->link.state, q921_state2str(link->link.state));
 		break;
 	case 'B':
 	case 'E':

[... 743 lines stripped ...]



More information about the libpri-commits mailing list