[svn-commits] rmudgett: branch rmudgett/subaddr_xfer r2158 - /team/rmudgett/subaddr_xfer/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Dec 7 20:12:57 CST 2010


Author: rmudgett
Date: Tue Dec  7 20:12:53 2010
New Revision: 2158

URL: http://svnview.digium.com/svn/libpri?view=rev&rev=2158
Log:
Receive connected line subaddress update messages.

Modified:
    team/rmudgett/subaddr_xfer/pri_facility.c
    team/rmudgett/subaddr_xfer/q931.c

Modified: team/rmudgett/subaddr_xfer/pri_facility.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/subaddr_xfer/pri_facility.c?view=diff&rev=2158&r1=2157&r2=2158
==============================================================================
--- team/rmudgett/subaddr_xfer/pri_facility.c (original)
+++ team/rmudgett/subaddr_xfer/pri_facility.c Tue Dec  7 20:12:53 2010
@@ -3561,6 +3561,87 @@
 	}
 
 	return 0;
+}
+
+/*!
+ * \internal
+ * \brief Handle the received RequestSubaddress facility.
+ *
+ * \param ctrl D channel controller.
+ * \param call Q.931 call leg
+ *
+ * \return Nothing
+ */
+static void etsi_request_subaddress(struct pri *ctrl, struct q931_call *call)
+{
+	int changed = 0;
+
+	switch (call->notify) {
+	case PRI_NOTIFY_TRANSFER_ACTIVE:
+		if (q931_party_number_cmp(&call->remote_id.number, &call->redirection_number)) {
+			/* The remote party number information changed. */
+			call->remote_id.number = call->redirection_number;
+			changed = 1;
+		}
+		/* Fall through */
+	case PRI_NOTIFY_TRANSFER_ALERTING:
+		if (call->redirection_number.valid
+			&& q931_party_number_cmp(&call->remote_id.number, &call->redirection_number)) {
+			/* The remote party number information changed. */
+			call->remote_id.number = call->redirection_number;
+			changed = 1;
+		}
+		if (call->remote_id.subaddress.valid) {
+			/*
+			 * Clear the subaddress as the remote party has been changed.
+			 * Any new subaddress will arrive later.
+			 */
+			q931_party_subaddress_init(&call->remote_id.subaddress);
+			changed = 1;
+		}
+		if (changed) {
+			call->incoming_ct_state = INCOMING_CT_STATE_POST_CONNECTED_LINE;
+		}
+		break;
+	default:
+		break;
+	}
+
+	if (call->local_id.subaddress.valid) {
+		send_subaddress_transfer(ctrl, call);
+	}
+}
+
+/*!
+ * \internal
+ * \brief Handle the received SubaddressTransfer facility subaddress.
+ *
+ * \param ctrl D channel controller.
+ * \param call Q.931 call leg
+ * \param subaddr Received subaddress of remote party.
+ *
+ * \return Nothing
+ */
+static void handle_subaddress_transfer(struct pri *ctrl, struct q931_call *call, const struct rosePartySubaddress *subaddr)
+{
+	int changed = 0;
+	struct q931_party_subaddress q931_subaddress;
+
+	q931_party_subaddress_init(&q931_subaddress);
+	rose_copy_subaddress_to_q931(ctrl, &q931_subaddress, subaddr);
+	if (q931_party_subaddress_cmp(&call->remote_id.subaddress, &q931_subaddress)) {
+		call->remote_id.subaddress = q931_subaddress;
+		changed = 1;
+	}
+	if (call->redirection_number.valid
+		&& q931_party_number_cmp(&call->remote_id.number, &call->redirection_number)) {
+		/* The remote party number information changed. */
+		call->remote_id.number = call->redirection_number;
+		changed = 1;
+	}
+	if (changed) {
+		call->incoming_ct_state = INCOMING_CT_STATE_POST_CONNECTED_LINE;
+	}
 }
 
 /*!
@@ -4580,12 +4661,12 @@
 		}
 		break;
 	case ROSE_ETSI_RequestSubaddress:
-		/* Ignore since we are not handling subaddresses yet. */
-		break;
-#if 0	/* Not handled yet */
+		etsi_request_subaddress(ctrl, call);
+		break;
 	case ROSE_ETSI_SubaddressTransfer:
-		break;
-#endif	/* Not handled yet */
+		handle_subaddress_transfer(ctrl, call,
+			&invoke->args.etsi.SubaddressTransfer.subaddress);
+		break;
 	case ROSE_ETSI_EctLinkIdRequest:
 		if (!ctrl->transfer_support) {
 			send_facility_error(ctrl, call, invoke->invoke_id,
@@ -5030,6 +5111,11 @@
 		} else {
 			call->incoming_ct_state = INCOMING_CT_STATE_POST_CONNECTED_LINE;
 		}
+
+		/* Send our subaddress back if we have one. */
+		if (call->local_id.subaddress.valid) {
+			send_subaddress_transfer(ctrl, call);
+		}
 		break;
 	case ROSE_QSIG_CallTransferUpdate:
 		party_id = call->remote_id;
@@ -5056,10 +5142,10 @@
 			}
 		}
 		break;
-#if 0	/* Not handled yet */
 	case ROSE_QSIG_SubaddressTransfer:
-		break;
-#endif	/* Not handled yet */
+		handle_subaddress_transfer(ctrl, call,
+			&invoke->args.qsig.SubaddressTransfer.redirection_subaddress);
+		break;
 	case ROSE_QSIG_PathReplacement:
 		anfpr_pathreplacement_respond(ctrl, call, ie);
 		break;

Modified: team/rmudgett/subaddr_xfer/q931.c
URL: http://svnview.digium.com/svn/libpri/team/rmudgett/subaddr_xfer/q931.c?view=diff&rev=2158&r1=2157&r2=2158
==============================================================================
--- team/rmudgett/subaddr_xfer/q931.c (original)
+++ team/rmudgett/subaddr_xfer/q931.c Tue Dec  7 20:12:53 2010
@@ -6375,6 +6375,8 @@
 		c->ri = -1;
 		break;
 	case Q931_FACILITY:
+		c->notify = -1;
+		q931_party_number_init(&c->redirection_number);
 		if (q931_is_dummy_call(c)) {
 			q931_party_address_init(&c->called);
 		}
@@ -6475,6 +6477,7 @@
 	case Q931_SETUP_ACKNOWLEDGE:
 		break;
 	case Q931_NOTIFY:
+		c->notify = -1;
 		q931_party_number_init(&c->redirection_number);
 		break;
 	case Q931_HOLD:
@@ -7606,6 +7609,7 @@
 static int post_handle_q931_message(struct pri *ctrl, struct q931_mh *mh, struct q931_call *c, int missingmand)
 {
 	int res;
+	int changed;
 	struct apdu_event *cur = NULL;
 	struct pri_subcommand *subcmd;
 	struct q931_call *master_call;
@@ -8182,6 +8186,7 @@
 		return Q931_RES_HAVEEVENT;
 	case Q931_NOTIFY:
 		res = 0;
+		changed = 0;
 		switch (c->notify) {
 		case PRI_NOTIFY_CALL_DIVERTING:
 			if (c->redirection_number.valid) {
@@ -8214,13 +8219,29 @@
 				res = Q931_RES_HAVEEVENT;
 			}
 			break;
+		case PRI_NOTIFY_TRANSFER_ACTIVE:
+			if (q931_party_number_cmp(&c->remote_id.number, &c->redirection_number)) {
+				/* The remote party number information changed. */
+				c->remote_id.number = c->redirection_number;
+				changed = 1;
+			}
+			/* Fall through */
 		case PRI_NOTIFY_TRANSFER_ALERTING:
-		case PRI_NOTIFY_TRANSFER_ACTIVE:
 			if (c->redirection_number.valid
 				&& q931_party_number_cmp(&c->remote_id.number, &c->redirection_number)) {
-				/* The remote party information changed. */
+				/* The remote party number information changed. */
 				c->remote_id.number = c->redirection_number;
-
+				changed = 1;
+			}
+			if (c->remote_id.subaddress.valid) {
+				/*
+				 * Clear the subaddress as the remote party has been changed.
+				 * Any new subaddress will arrive later.
+				 */
+				q931_party_subaddress_init(&c->remote_id.subaddress);
+				changed = 1;
+			}
+			if (changed) {
 				/* Setup connected line subcommand */
 				subcmd = q931_alloc_subcommand(ctrl);
 				if (subcmd) {




More information about the svn-commits mailing list