[libpri-commits] rmudgett: branch group/issue14068 r828 - /team/group/issue14068/

SVN commits to the libpri project libpri-commits at lists.digium.com
Fri May 29 16:27:34 CDT 2009


Author: rmudgett
Date: Fri May 29 16:27:31 2009
New Revision: 828

URL: http://svn.asterisk.org/svn-view/libpri?view=rev&rev=828
Log:
Implemented the local and remote party to make it easier to keep track of who's information we are dealing.

The Caller-ID and connected-line ID are just roles the local and remote party
play while a call is being established.  Which roll depends upon the direction
of the call.
Outgoing party info is to identify the local party to the other end.
   (Caller-ID for originated or connected-line for answered calls.)
Incoming party info is to identify the remote party to us.
   (Caller-ID for answered or connected-line for originated calls.)

Modified:
    team/group/issue14068/pri.c
    team/group/issue14068/pri_facility.c
    team/group/issue14068/pri_internal.h
    team/group/issue14068/q931.c

Modified: team/group/issue14068/pri.c
URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14068/pri.c?view=diff&rev=828&r1=827&r2=828
==============================================================================
--- team/group/issue14068/pri.c (original)
+++ team/group/issue14068/pri.c Fri May 29 16:27:31 2009
@@ -565,20 +565,20 @@
 	if (!pri || !call)
 		return -1;
 
-	call->connected_line.number.status = Q931_PARTY_DATA_STATUS_CHANGED;
-	call->connected_line.number.presentation = connected->id.number_presentation;
-	call->connected_line.number.plan = connected->id.number_type;
-	libpri_copy_string(call->connected_line.number.str, connected->id.number,
-		sizeof(call->connected_line.number.str));
+	call->local_id.number.status = Q931_PARTY_DATA_STATUS_CHANGED;
+	call->local_id.number.presentation = connected->id.number_presentation;
+	call->local_id.number.plan = connected->id.number_type;
+	libpri_copy_string(call->local_id.number.str, connected->id.number,
+		sizeof(call->local_id.number.str));
 
 	if (connected->id.name[0]) {
-		call->connected_line.name.status = Q931_PARTY_DATA_STATUS_CHANGED;
-		call->connected_line.name.presentation = connected->id.number_presentation;
-		call->connected_line.name.char_set = 1;	/* iso8859-1 */
-		libpri_copy_string(call->connected_line.name.str, connected->id.name,
-			sizeof(call->connected_line.name.str));
+		call->local_id.name.status = Q931_PARTY_DATA_STATUS_CHANGED;
+		call->local_id.name.presentation = connected->id.number_presentation;
+		call->local_id.name.char_set = 1;	/* iso8859-1 */
+		libpri_copy_string(call->local_id.name.str, connected->id.name,
+			sizeof(call->local_id.name.str));
 	} else {
-		q931_party_name_init(&call->connected_line.name);
+		q931_party_name_init(&call->local_id.name);
 	}
 
 	if (pri->switchtype == PRI_SWITCH_QSIG) {
@@ -590,13 +590,13 @@
 		case Q931_CALL_STATE_OVERLAP_RECEIVING:
 		case Q931_CALL_STATE_INCOMING_CALL_PROCEEDING:
 			/* queue updates for next ALERTING */
-			if (call->connected_line.name.str[0]) {
+			if (call->local_id.name.str[0]) {
 				/* queue connectedName to be send with next Q931_ALERTING */
 				rose_called_name_encode(pri, call, Q931_ALERTING);
 			}
 
 			if (call->redirecting.state != DIVERTEDSTATE_NONE) {
-				call->redirecting.to = call->connected_line;
+				call->redirecting.to = call->local_id;
 
 				if ((call->redirecting.state == DIVERTEDSTATE_DIVERTED) && call->redirecting.to.number.str[0]) {
 					/* immediately send divertingLegInformation1 APDU  */
@@ -612,13 +612,13 @@
 			break;
 		case Q931_CALL_STATE_CALL_RECEIVED:
 			/* queue updates for next CONNECT */
-			if (call->connected_line.name.str[0] && ((call->redirecting.state == DIVERTEDSTATE_NONE) || (call->redirecting.state == DIVERTEDSTATE_DIVLEGINFO3SEND))) {
+			if (call->local_id.name.str[0] && ((call->redirecting.state == DIVERTEDSTATE_NONE) || (call->redirecting.state == DIVERTEDSTATE_DIVLEGINFO3SEND))) {
 				/* queue connectedName to be send with next Q931_CONNECT */
 				rose_connected_name_encode(pri, call, Q931_CONNECT);
 			}
 
 			if (call->redirecting.state != DIVERTEDSTATE_NONE) {
-				call->redirecting.to = call->connected_line;
+				call->redirecting.to = call->local_id;
 
 				if ((call->redirecting.state == DIVERTEDSTATE_DIVERTED) && call->redirecting.to.number.str[0]) {
 					/* queue divertingLegInformation1 to be send with next Q931_FACILITY */

Modified: team/group/issue14068/pri_facility.c
URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14068/pri_facility.c?view=diff&rev=828&r1=827&r2=828
==============================================================================
--- team/group/issue14068/pri_facility.c (original)
+++ team/group/issue14068/pri_facility.c Fri May 29 16:27:31 2009
@@ -918,13 +918,13 @@
  * \param ctrl D channel controller for diagnostic messages or global options.
  * \param pos Starting position to encode the facility ie contents.
  * \param end End of facility ie contents encoding data buffer.
- * \param call Call leg from which to encode name.
+ * \param name Name data which to encode name.
  *
  * \retval Start of the next ASN.1 component to encode on success.
  * \retval NULL on error.
  */
 static unsigned char *enc_qsig_calling_name(struct pri *ctrl, unsigned char *pos,
-	unsigned char *end, q931_call *call)
+	unsigned char *end, const struct q931_party_name *name)
 {
 	struct fac_extension_header header;
 	struct rose_msg_invoke msg;
@@ -946,13 +946,13 @@
 	msg.operation = ROSE_QSIG_CallingName;
 	msg.invoke_id = get_invokeid(ctrl);
 
-	/* CallingName is the caller_id.name */
+	/* CallingName */
 	msg.args.qsig.CallingName.name.presentation = qsig_name_presentation_from_q931(ctrl,
-		call->caller_id.name.presentation, call->caller_id.name.str[0]);
-	msg.args.qsig.CallingName.name.char_set = call->caller_id.name.char_set;
-	/* Truncate the caller_id.name.str if necessary. */
+		name->presentation, name->str[0]);
+	msg.args.qsig.CallingName.name.char_set = name->char_set;
+	/* Truncate the name->str if necessary. */
 	libpri_copy_string((char *) msg.args.qsig.CallingName.name.data,
-		call->caller_id.name.str, sizeof(msg.args.qsig.CallingName.name.data));
+		name->str, sizeof(msg.args.qsig.CallingName.name.data));
 	msg.args.qsig.CallingName.name.length =
 		strlen((char *) msg.args.qsig.CallingName.name.data);
 	pos = rose_encode_invoke(ctrl, pos, end, &msg);
@@ -979,7 +979,7 @@
 	unsigned char *end;
 	int mymessage;
 
-	if (call->caller_id.name.status == Q931_PARTY_DATA_STATUS_INVALID) {
+	if (call->local_id.name.status == Q931_PARTY_DATA_STATUS_INVALID) {
 		return 0;
 	}
 
@@ -999,8 +999,10 @@
 		 */
 	}
 
-	call->caller_id.name.status = Q931_PARTY_DATA_STATUS_VALID;
-	end = enc_qsig_calling_name(ctrl, buffer, buffer + sizeof(buffer), call);
+	/* CallingName is the local_id.name */
+	call->local_id.name.status = Q931_PARTY_DATA_STATUS_VALID;
+	end = enc_qsig_calling_name(ctrl, buffer, buffer + sizeof(buffer),
+		&call->local_id.name);
 	if (!end) {
 		return -1;
 	}
@@ -1340,9 +1342,13 @@
 	unsigned char *end;
 	int res;
 
+	/*
+	 * We are deflecting an incoming call back to the network.
+	 * Therefore, the Caller-ID is the remote party.
+	 */
 	end =
 		enc_qsig_call_rerouting(ctrl, buffer, buffer + sizeof(buffer),
-			call->caller_id.number.str, dest, original ? original :
+			call->remote_id.number.str, dest, original ? original :
 			call->called_number.str, reason);
 	if (!end) {
 		return -1;
@@ -1622,36 +1628,36 @@
 	msg.invoke_id = get_invokeid(ctrl);
 	msg.args.qsig.CallTransferComplete.end_designation = 0;	/* primaryEnd */
 
-	/* redirectionNumber is the connected_line.number */
+	/* redirectionNumber is the local_id.number */
 	msg.args.qsig.CallTransferComplete.redirection.presentation =
-		presentation_from_q931(ctrl, call->connected_line.number.presentation,
-			call->connected_line.number.str[0]);
+		presentation_from_q931(ctrl, call->local_id.number.presentation,
+			call->local_id.number.str[0]);
 	msg.args.qsig.CallTransferComplete.redirection.screened.screening_indicator =
-		call->connected_line.number.presentation & 0x03;
+		call->local_id.number.presentation & 0x03;
 	msg.args.qsig.CallTransferComplete.redirection.screened.number.plan =
-		numbering_plan_from_q931(ctrl, call->connected_line.number.plan);
+		numbering_plan_from_q931(ctrl, call->local_id.number.plan);
 	msg.args.qsig.CallTransferComplete.redirection.screened.number.ton =
-		typeofnumber_from_q931(ctrl, call->connected_line.number.plan);
+		typeofnumber_from_q931(ctrl, call->local_id.number.plan);
 	libpri_copy_string((char *)
 		msg.args.qsig.CallTransferComplete.redirection.screened.number.str,
-		call->connected_line.number.str,
+		call->local_id.number.str,
 		sizeof(msg.args.qsig.CallTransferComplete.redirection.screened.number.str));
 	msg.args.qsig.CallTransferComplete.redirection.screened.number.length =
 		strlen((char *)
 		msg.args.qsig.CallTransferComplete.redirection.screened.number.str);
 
-	/* redirectionName is the connected_line.name */
-	if (call->connected_line.name.status != Q931_PARTY_DATA_STATUS_INVALID) {
-		call->connected_line.name.status = Q931_PARTY_DATA_STATUS_VALID;
+	/* redirectionName is the local_id.name */
+	if (call->local_id.name.status != Q931_PARTY_DATA_STATUS_INVALID) {
+		call->local_id.name.status = Q931_PARTY_DATA_STATUS_VALID;
 		msg.args.qsig.CallTransferComplete.redirection_name.presentation =
 			qsig_name_presentation_from_q931(ctrl,
-				call->connected_line.name.presentation,
-				call->connected_line.name.str[0]);
+				call->local_id.name.presentation,
+				call->local_id.name.str[0]);
 		msg.args.qsig.CallTransferComplete.redirection_name.char_set =
-			call->connected_line.name.char_set;
+			call->local_id.name.char_set;
 		libpri_copy_string((char *)
 			msg.args.qsig.CallTransferComplete.redirection_name.data,
-			call->connected_line.name.str,
+			call->local_id.name.str,
 			sizeof(msg.args.qsig.CallTransferComplete.redirection_name.data));
 		msg.args.qsig.CallTransferComplete.redirection_name.length =
 			strlen((char *) msg.args.qsig.CallTransferComplete.redirection_name.data);
@@ -1701,13 +1707,13 @@
  * \param ctrl D channel controller for diagnostic messages or global options.
  * \param pos Starting position to encode the facility ie contents.
  * \param end End of facility ie contents encoding data buffer.
- * \param call Call leg from which to encode name.
+ * \param name Name data which to encode name.
  *
  * \retval Start of the next ASN.1 component to encode on success.
  * \retval NULL on error.
  */
 static unsigned char *enc_qsig_called_name(struct pri *ctrl, unsigned char *pos,
-	unsigned char *end, q931_call *call)
+	unsigned char *end, const struct q931_party_name *name)
 {
 	struct fac_extension_header header;
 	struct rose_msg_invoke msg;
@@ -1727,12 +1733,12 @@
 	msg.operation = ROSE_QSIG_CalledName;
 	msg.invoke_id = get_invokeid(ctrl);
 
-	/* CalledName is the connected_line.name */
+	/* CalledName */
 	msg.args.qsig.CalledName.name.presentation = qsig_name_presentation_from_q931(ctrl,
-		call->connected_line.name.presentation, call->connected_line.name.str[0]);
-	msg.args.qsig.CalledName.name.char_set = call->connected_line.name.char_set;
+		name->presentation, name->str[0]);
+	msg.args.qsig.CalledName.name.char_set = name->char_set;
 	libpri_copy_string((char *)
-		msg.args.qsig.CalledName.name.data, call->connected_line.name.str,
+		msg.args.qsig.CalledName.name.data, name->str,
 		sizeof(msg.args.qsig.CalledName.name.data));
 	msg.args.qsig.CalledName.name.length =
 		strlen((char *) msg.args.qsig.CalledName.name.data);
@@ -1757,7 +1763,9 @@
 	unsigned char buffer[256];
 	unsigned char *end;
 
-	end = enc_qsig_called_name(ctrl, buffer, buffer + sizeof(buffer), call);
+	/* CalledName is the local_id.name */
+	end = enc_qsig_called_name(ctrl, buffer, buffer + sizeof(buffer),
+		&call->local_id.name);
 	if (!end) {
 		return -1;
 	}
@@ -1772,13 +1780,13 @@
  * \param ctrl D channel controller for diagnostic messages or global options.
  * \param pos Starting position to encode the facility ie contents.
  * \param end End of facility ie contents encoding data buffer.
- * \param call Call leg from which to encode name.
+ * \param name Name data which to encode name.
  *
  * \retval Start of the next ASN.1 component to encode on success.
  * \retval NULL on error.
  */
 static unsigned char *enc_qsig_connected_name(struct pri *ctrl, unsigned char *pos,
-	unsigned char *end, q931_call *call)
+	unsigned char *end, const struct q931_party_name *name)
 {
 	struct fac_extension_header header;
 	struct rose_msg_invoke msg;
@@ -1798,12 +1806,12 @@
 	msg.operation = ROSE_QSIG_ConnectedName;
 	msg.invoke_id = get_invokeid(ctrl);
 
-	/* ConnectedName is the connected_line.name */
+	/* ConnectedName */
 	msg.args.qsig.ConnectedName.name.presentation = qsig_name_presentation_from_q931(ctrl,
-		call->connected_line.name.presentation, call->connected_line.name.str[0]);
-	msg.args.qsig.ConnectedName.name.char_set = call->connected_line.name.char_set;
+		name->presentation, name->str[0]);
+	msg.args.qsig.ConnectedName.name.char_set = name->char_set;
 	libpri_copy_string((char *)
-		msg.args.qsig.ConnectedName.name.data, call->connected_line.name.str,
+		msg.args.qsig.ConnectedName.name.data, name->str,
 		sizeof(msg.args.qsig.ConnectedName.name.data));
 	msg.args.qsig.ConnectedName.name.length =
 		strlen((char *) msg.args.qsig.ConnectedName.name.data);
@@ -1828,7 +1836,9 @@
 	unsigned char buffer[256];
 	unsigned char *end;
 
-	end = enc_qsig_connected_name(ctrl, buffer, buffer + sizeof(buffer), call);
+	/* ConnectedName is the local_id.name */
+	end = enc_qsig_connected_name(ctrl, buffer, buffer + sizeof(buffer),
+		&call->local_id.name);
 	if (!end) {
 		return -1;
 	}
@@ -2262,35 +2272,35 @@
 		break;
 #endif	/* Not handled yet */
 	case ROSE_QSIG_CallingName:
-		/* CallingName is put in caller_id.name */
-		call->caller_id.name.status = Q931_PARTY_DATA_STATUS_CHANGED;
-		call->caller_id.name.presentation = qsig_name_presentation_for_q931(ctrl,
+		/* CallingName is put in remote_id.name */
+		call->remote_id.name.status = Q931_PARTY_DATA_STATUS_CHANGED;
+		call->remote_id.name.presentation = qsig_name_presentation_for_q931(ctrl,
 			invoke->args.qsig.CallingName.name.presentation);
-		call->caller_id.name.char_set = invoke->args.qsig.CallingName.name.char_set;
-		libpri_copy_string(call->caller_id.name.str,
+		call->remote_id.name.char_set = invoke->args.qsig.CallingName.name.char_set;
+		libpri_copy_string(call->remote_id.name.str,
 			(char *) invoke->args.qsig.CallingName.name.data,
-			sizeof(call->caller_id.name.str));
+			sizeof(call->remote_id.name.str));
 		break;
 	case ROSE_QSIG_CalledName:
-		/* CalledName is put in called.name */
-		call->called_name.status = Q931_PARTY_DATA_STATUS_CHANGED;
-		call->called_name.presentation = qsig_name_presentation_for_q931(ctrl,
+		/* CalledName is put in remote_id.name */
+		call->remote_id.name.status = Q931_PARTY_DATA_STATUS_CHANGED;
+		call->remote_id.name.presentation = qsig_name_presentation_for_q931(ctrl,
 			invoke->args.qsig.CalledName.name.presentation);
-		call->called_name.char_set = invoke->args.qsig.CalledName.name.char_set;
-		libpri_copy_string(call->called_name.str,
+		call->remote_id.name.char_set = invoke->args.qsig.CalledName.name.char_set;
+		libpri_copy_string(call->remote_id.name.str,
 			(char *) invoke->args.qsig.CalledName.name.data,
-			sizeof(call->called_name.str));
+			sizeof(call->remote_id.name.str));
 		break;
 	case ROSE_QSIG_ConnectedName:
-		/* ConnectedName is put in connected_line.name */
-		call->connected_line.name.status = Q931_PARTY_DATA_STATUS_CHANGED;
-		call->connected_line.name.presentation = qsig_name_presentation_for_q931(ctrl,
+		/* ConnectedName is put in remote_id.name */
+		call->remote_id.name.status = Q931_PARTY_DATA_STATUS_CHANGED;
+		call->remote_id.name.presentation = qsig_name_presentation_for_q931(ctrl,
 			invoke->args.qsig.ConnectedName.name.presentation);
-		call->connected_line.name.char_set =
+		call->remote_id.name.char_set =
 			invoke->args.qsig.ConnectedName.name.char_set;
-		libpri_copy_string(call->connected_line.name.str,
+		libpri_copy_string(call->remote_id.name.str,
 			(char *) invoke->args.qsig.ConnectedName.name.data,
-			sizeof(call->connected_line.name.str));
+			sizeof(call->remote_id.name.str));
 		break;
 #if 0	/* Not handled yet */
 	case ROSE_QSIG_BusyName:
@@ -2414,22 +2424,22 @@
 		switch (invoke->args.qsig.CallTransferUpdate.redirection.presentation) {
 		case 0:	/* presentationAllowedNumber */
 		case 3:	/* presentationRestrictedNumber */
-			libpri_copy_string(call->caller_id.number.str, (char *)
+			libpri_copy_string(call->remote_id.number.str, (char *)
 				invoke->args.qsig.CallTransferUpdate.redirection.screened.number.str,
-				sizeof(call->caller_id.number.str));
+				sizeof(call->remote_id.number.str));
 			break;
 		default:
-			call->caller_id.number.str[0] = '\0';
-			break;
-		}
-		call->caller_id.name.str[0] = '\0';
+			call->remote_id.number.str[0] = '\0';
+			break;
+		}
+		call->remote_id.name.str[0] = '\0';
 		if (invoke->args.qsig.CallTransferUpdate.redirection_name_present) {
 			switch (invoke->args.qsig.CallTransferUpdate.redirection_name.presentation) {
 			case 1:	/* presentation_allowed */
 			case 2:	/* presentation_restricted */
-				libpri_copy_string(call->caller_id.name.str,
+				libpri_copy_string(call->remote_id.name.str,
 					(char *) invoke->args.qsig.CallTransferUpdate.redirection_name.data,
-					sizeof(call->caller_id.name.str));
+					sizeof(call->remote_id.name.str));
 				break;
 			default:
 				break;

Modified: team/group/issue14068/pri_internal.h
URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14068/pri_internal.h?view=diff&rev=828&r1=827&r2=828
==============================================================================
--- team/group/issue14068/pri_internal.h (original)
+++ team/group/issue14068/pri_internal.h Fri May 29 16:27:31 2009
@@ -333,11 +333,32 @@
 	/*! Current dialed digits to be sent or just received. */
 	char overlap_digits[PRI_MAX_NUMBER_LEN];
 
-/* BUGBUG need to check usage of elements in caller_id */
-	struct q931_party_id caller_id;
-
-/* BUGBUG need to check usage of elements in called_name */
-	struct q931_party_name called_name;
+	/*!
+	 * \brief Local party ID
+	 * \details
+	 * The Caller-ID and connected-line ID are just roles the local and remote party
+	 * play while a call is being established.  Which roll depends upon the direction
+	 * of the call.
+	 * Outgoing party info is to identify the local party to the other end.
+	 *    (Caller-ID for originated or connected-line for answered calls.)
+	 * Incoming party info is to identify the remote party to us.
+	 *    (Caller-ID for answered or connected-line for originated calls.)
+	 */
+/* BUGBUG need to check usage of elements in local_id */
+	struct q931_party_id local_id;
+	/*!
+	 * \brief Remote party ID
+	 * \details
+	 * The Caller-ID and connected-line ID are just roles the local and remote party
+	 * play while a call is being established.  Which roll depends upon the direction
+	 * of the call.
+	 * Outgoing party info is to identify the local party to the other end.
+	 *    (Caller-ID for originated or connected-line for answered calls.)
+	 * Incoming party info is to identify the remote party to us.
+	 *    (Caller-ID for answered or connected-line for originated calls.)
+	 */
+/* BUGBUG need to check usage of elements in remote_id */
+	struct q931_party_id remote_id;
 
 	/*!
 	 * \brief Called party number.
@@ -364,11 +385,11 @@
 /* BUGBUG need to check usage of elements in orig_called */
 	struct q931_party_id orig_called;
 
-/* BUGBUG need to check usage of elements in connected_line */
-	struct q931_party_id connected_line;
 /* BUGBUG need to check usage of elements in ct_complete */
+/* BUGBUG This will also become part of local/remote party id behaviour. */
 	struct q931_party_id ct_complete;
 /* BUGBUG need to check usage of elements in ct_active */
+/* BUGBUG This will also become part of local/remote party id behaviour. */
 	struct q931_party_id ct_active;
 
 	/* divertingLegInformation1 */

Modified: team/group/issue14068/q931.c
URL: http://svn.asterisk.org/svn-view/libpri/team/group/issue14068/q931.c?view=diff&rev=828&r1=827&r2=828
==============================================================================
--- team/group/issue14068/q931.c (original)
+++ team/group/issue14068/q931.c Fri May 29 16:27:31 2009
@@ -1145,24 +1145,24 @@
 {
 	int i = 0;
 
-	call->connected_line.number.status = Q931_PARTY_DATA_STATUS_CHANGED;
-	call->connected_line.number.presentation =
+	call->remote_id.number.status = Q931_PARTY_DATA_STATUS_CHANGED;
+	call->remote_id.number.presentation =
 		PRI_PRES_ALLOWED | PRI_PRES_USER_NUMBER_UNSCREENED;
 	/* To follow Q.931 (4.5.1), we must search for start of octet 4 by
 	   walking through all bytes until one with ext bit (8) set to 1 */
 	do {
 		switch (i) {
 		case 0:
-			call->connected_line.number.plan = ie->data[i] & 0x7f;
+			call->remote_id.number.plan = ie->data[i] & 0x7f;
 			break;
 		case 1:
 			/* Keep only the presentation and screening fields */
-			call->connected_line.number.presentation =
+			call->remote_id.number.presentation =
 				ie->data[i] & (PRI_PRES_RESTRICTION | PRI_PRES_NUMBER_TYPE);
 			break;
 		}
 	} while (!(ie->data[i++] & 0x80));
-	q931_get_number((unsigned char *) call->connected_line.number.str, sizeof(call->connected_line.number.str), ie->data + i, ie->len - i);
+	q931_get_number((unsigned char *) call->remote_id.number.str, sizeof(call->remote_id.number.str), ie->data + i, ie->len - i);
 
 	return 0;
 }
@@ -1171,15 +1171,15 @@
 {
 	size_t datalen;
 
-	if (call->connected_line.number.status == Q931_PARTY_DATA_STATUS_INVALID) {
+	if (call->local_id.number.status == Q931_PARTY_DATA_STATUS_INVALID) {
 		return 0;
 	}
-	call->connected_line.number.status = Q931_PARTY_DATA_STATUS_VALID;
-
-	datalen = strlen(call->connected_line.number.str);
-	ie->data[0] = call->connected_line.number.plan;
-	ie->data[1] = 0x80 | call->connected_line.number.presentation;
-	memcpy(ie->data + 2, call->connected_line.number.str, datalen);
+	call->local_id.number.status = Q931_PARTY_DATA_STATUS_VALID;
+
+	datalen = strlen(call->local_id.number.str);
+	ie->data[0] = call->local_id.number.plan;
+	ie->data[1] = 0x80 | call->local_id.number.presentation;
+	memcpy(ie->data + 2, call->local_id.number.str, datalen);
 	return datalen + (2 + 2);
 }
 
@@ -1326,25 +1326,25 @@
 {
 	int i = 0;
 
-	call->caller_id.number.status = Q931_PARTY_DATA_STATUS_CHANGED;
-	call->caller_id.number.presentation =
+	call->remote_id.number.status = Q931_PARTY_DATA_STATUS_CHANGED;
+	call->remote_id.number.presentation =
 		PRI_PRES_ALLOWED | PRI_PRES_USER_NUMBER_UNSCREENED;
 	/* To follow Q.931 (4.5.1), we must search for start of octet 4 by
 	   walking through all bytes until one with ext bit (8) set to 1 */
 	do {
 		switch (i) {
 		case 0:
-			call->caller_id.number.plan = ie->data[i] & 0x7f;
+			call->remote_id.number.plan = ie->data[i] & 0x7f;
 			break;
 		case 1:
 			/* Keep only the presentation and screening fields */
-			call->caller_id.number.presentation =
+			call->remote_id.number.presentation =
 				ie->data[i] & (PRI_PRES_RESTRICTION | PRI_PRES_NUMBER_TYPE);
 			break;
 		}
 	} while (!(ie->data[i++] & 0x80));
-	q931_get_number((unsigned char *) call->caller_id.number.str,
-		sizeof(call->caller_id.number.str), ie->data + i, ie->len - i);
+	q931_get_number((unsigned char *) call->remote_id.number.str,
+		sizeof(call->remote_id.number.str), ie->data + i, ie->len - i);
 
 	return 0;
 }
@@ -1353,15 +1353,15 @@
 {
 	size_t datalen;
 
-	if (call->caller_id.number.status == Q931_PARTY_DATA_STATUS_INVALID) {
+	if (call->local_id.number.status == Q931_PARTY_DATA_STATUS_INVALID) {
 		return 0;
 	}
-	call->caller_id.number.status = Q931_PARTY_DATA_STATUS_VALID;
-
-	datalen = strlen(call->caller_id.number.str);
-	ie->data[0] = call->caller_id.number.plan;
-	ie->data[1] = 0x80 | call->caller_id.number.presentation;
-	memcpy(ie->data + 2, call->caller_id.number.str, datalen);
+	call->local_id.number.status = Q931_PARTY_DATA_STATUS_VALID;
+
+	datalen = strlen(call->local_id.number.str);
+	ie->data[0] = call->local_id.number.plan;
+	ie->data[1] = 0x80 | call->local_id.number.presentation;
+	memcpy(ie->data + 2, call->local_id.number.str, datalen);
 	return datalen + (2 + 2);
 }
 
@@ -1482,7 +1482,7 @@
 {
 	unsigned char *data;
 
-	call->caller_id.name.status = Q931_PARTY_DATA_STATUS_CHANGED;
+	call->remote_id.name.status = Q931_PARTY_DATA_STATUS_CHANGED;
 
 	data = ie->data;
 	if (data[0] & 0x80) {
@@ -1490,13 +1490,13 @@
 		data++;
 		len--;
 	}
-	call->caller_id.name.char_set = 1;	/* iso8859-1 */
-
-	q931_get_number((unsigned char *) call->caller_id.name.str, sizeof(call->caller_id.name.str), data, len - 2);
-	if (call->caller_id.name.str[0]) {
-		call->caller_id.name.presentation = PRI_PRES_ALLOWED;
+	call->remote_id.name.char_set = 1;	/* iso8859-1 */
+
+	q931_get_number((unsigned char *) call->remote_id.name.str, sizeof(call->remote_id.name.str), data, len - 2);
+	if (call->remote_id.name.str[0]) {
+		call->remote_id.name.presentation = PRI_PRES_ALLOWED;
 	} else {
-		call->caller_id.name.presentation = PRI_PRES_RESTRICTED;
+		call->remote_id.name.presentation = PRI_PRES_RESTRICTED;
 	}
 	return 0;
 }
@@ -1508,8 +1508,8 @@
 
 	i = 0;
 
-	if (call->caller_id.name.status == Q931_PARTY_DATA_STATUS_INVALID
-		|| !call->caller_id.name.str[0]) {
+	if (call->local_id.name.status == Q931_PARTY_DATA_STATUS_INVALID
+		|| !call->local_id.name.str[0]) {
 		return 0;
 	}
 	switch (ctrl->switchtype) {
@@ -1529,8 +1529,8 @@
 		break;
 	}
 
-	datalen = strlen(call->caller_id.name.str);
-	memcpy(ie->data + i, call->caller_id.name.str, datalen);
+	datalen = strlen(call->local_id.name.str);
+	memcpy(ie->data + i, call->local_id.name.str, datalen);
 	return 2 + i + datalen;
 }
 
@@ -2295,13 +2295,13 @@
 		break;
 #if 0
 	case 5:		/* Callid */
-		if (call->caller_id.number.status == Q931_PARTY_DATA_STATUS_INVALID) {
-			call->caller_id.number.status = Q931_PARTY_DATA_STATUS_CHANGED;
-			call->caller_id.number.presentation =
+		if (call->remote_id.number.status == Q931_PARTY_DATA_STATUS_INVALID) {
+			call->remote_id.number.status = Q931_PARTY_DATA_STATUS_CHANGED;
+			call->remote_id.number.presentation =
 				PRI_PRES_ALLOWED | PRI_PRES_USER_NUMBER_UNSCREENED;
-			call->caller_id.number.plan = PRI_UNKNOWN;
-			libpri_copy_string(call->caller_id.number.str, number,
-				sizeof(call->caller_id.number.str));
+			call->remote_id.number.plan = PRI_UNKNOWN;
+			libpri_copy_string(call->remote_id.number.str, number,
+				sizeof(call->remote_id.number.str));
 		}
 		break;
 #endif
@@ -2638,11 +2638,10 @@
 	cur->useruserprotocoldisc = -1;
 	cur->aoc_units = -1;
 	cur->changestatus = -1;
-	q931_party_id_init(&cur->caller_id);
-	q931_party_name_init(&cur->called_name);
 	q931_party_number_init(&cur->called_number);
+	q931_party_id_init(&cur->local_id);
+	q931_party_id_init(&cur->remote_id);
 	q931_party_id_init(&cur->orig_called);
-	q931_party_id_init(&cur->connected_line);
 	q931_party_id_init(&cur->ct_complete);
 	q931_party_id_init(&cur->ct_active);
 	q931_party_redirecting_init(&cur->redirecting);
@@ -3410,7 +3409,7 @@
 	else if (c->channelno)
 		c->chanflags = FLAG_PREFERRED;
 	if (req->caller) {
-		c->caller_id.number.status = Q931_PARTY_DATA_STATUS_CHANGED;
+		c->local_id.number.status = Q931_PARTY_DATA_STATUS_CHANGED;
 		switch (ctrl->switchtype) {
 		case PRI_SWITCH_DMS100:
 		case PRI_SWITCH_ATT4ESS:
@@ -3422,16 +3421,16 @@
 		default:
 			break;
 		}
-		c->caller_id.number.presentation = req->callerpres;
-		c->caller_id.number.plan = req->callerplan;
-		libpri_copy_string(c->caller_id.number.str, req->caller,
-			sizeof(c->caller_id.number.str));
+		c->local_id.number.presentation = req->callerpres;
+		c->local_id.number.plan = req->callerplan;
+		libpri_copy_string(c->local_id.number.str, req->caller,
+			sizeof(c->local_id.number.str));
 		if (req->callername) {
-			c->caller_id.name.status = Q931_PARTY_DATA_STATUS_CHANGED;
-			c->caller_id.name.presentation = req->callerpres;
-			c->caller_id.name.char_set = 1;	/* iso8859-1 */
-			libpri_copy_string(c->caller_id.name.str, req->callername,
-				sizeof(c->caller_id.name.str));
+			c->local_id.name.status = Q931_PARTY_DATA_STATUS_CHANGED;
+			c->local_id.name.presentation = req->callerpres;
+			c->local_id.name.char_set = 1;	/* iso8859-1 */
+			libpri_copy_string(c->local_id.name.str, req->callername,
+				sizeof(c->local_id.name.str));
 		}
 	}
 	if (req->redirectingnum && req->redirectingnum[0]) {
@@ -3683,7 +3682,6 @@
 		c->ri = -1;
 		break;
 	case Q931_FACILITY:
-		q931_party_name_init(&c->caller_id.name);
 		break;
 	case Q931_SETUP:
 		if (ctrl->debug & PRI_DEBUG_Q931_STATE)
@@ -3701,15 +3699,14 @@
 		c->userl3 = -1;
 		c->rateadaption = -1;
 
-		q931_party_name_init(&c->called_name);
 		q931_party_number_init(&c->called_number);
-		q931_party_id_init(&c->caller_id);
+		q931_party_id_init(&c->local_id);
+		q931_party_id_init(&c->remote_id);
 		q931_party_redirecting_init(&c->redirecting);
 
 		c->origredirectingreason = -1;
 		q931_party_id_init(&c->orig_called);
 
-		q931_party_id_init(&c->connected_line);
 
 		c->divleginfo1activeflag = 0;
 		c->divleginfo3activeflag = 0;
@@ -4052,12 +4049,12 @@
 		ctrl->ev.e = PRI_EVENT_RING;
 		ctrl->ev.ring.subcmds = &ctrl->subcmds;
 		ctrl->ev.ring.channel = c->channelno | (c->ds1no << 8) | (c->ds1explicit << 16);
-		ctrl->ev.ring.callingpres = q931_party_id_presentation(&c->caller_id);
-		ctrl->ev.ring.callingplan = c->caller_id.number.plan;
-		if (c->caller_id.number.presentation == PRES_ALLOWED_NETWORK_NUMBER ||
-			c->caller_id.number.presentation == PRES_PROHIB_NETWORK_NUMBER) {
-			ctrl->ev.ring.callingplanani = c->caller_id.number.plan;
-			libpri_copy_string(ctrl->ev.ring.callingani, c->caller_id.number.str, sizeof(ctrl->ev.ring.callingani));
+		ctrl->ev.ring.callingpres = q931_party_id_presentation(&c->remote_id);
+		ctrl->ev.ring.callingplan = c->remote_id.number.plan;
+		if (c->remote_id.number.presentation == PRES_ALLOWED_NETWORK_NUMBER ||
+			c->remote_id.number.presentation == PRES_PROHIB_NETWORK_NUMBER) {
+			ctrl->ev.ring.callingplanani = c->remote_id.number.plan;
+			libpri_copy_string(ctrl->ev.ring.callingani, c->remote_id.number.str, sizeof(ctrl->ev.ring.callingani));
 		} else {
 			ctrl->ev.ring.callingplanani = -1;
 			ctrl->ev.ring.callingani[0] = '\0';
@@ -4065,8 +4062,8 @@
 		ctrl->ev.ring.callingplanrdnis = c->redirecting.from.number.plan;
 		ctrl->ev.ring.callingplanorigcalled = c->orig_called.number.plan;
 		ctrl->ev.ring.ani2 = c->ani2;
-		libpri_copy_string(ctrl->ev.ring.callingnum, c->caller_id.number.str, sizeof(ctrl->ev.ring.callingnum));
-		libpri_copy_string(ctrl->ev.ring.callingname, c->caller_id.name.str, sizeof(ctrl->ev.ring.callingname));
+		libpri_copy_string(ctrl->ev.ring.callingnum, c->remote_id.number.str, sizeof(ctrl->ev.ring.callingnum));
+		libpri_copy_string(ctrl->ev.ring.callingname, c->remote_id.name.str, sizeof(ctrl->ev.ring.callingname));
 		ctrl->ev.ring.calledplan = c->called_number.plan;
 		libpri_copy_string(ctrl->ev.ring.callingsubaddr, c->callingsubaddr, sizeof(ctrl->ev.ring.callingsubaddr));
 		libpri_copy_string(ctrl->ev.ring.callednum, c->called_number.str, sizeof(ctrl->ev.ring.callednum));
@@ -4111,9 +4108,9 @@
 			ctrl->ev.ringing.calledpres = q931_party_id_presentation(&c->redirecting.to);
 			ctrl->ev.ringing.calledplan = c->redirecting.to.number.plan;
 		} else {
-			libpri_copy_string(ctrl->ev.ringing.calledname, c->called_name.str, sizeof(ctrl->ev.ringing.calledname));
+			libpri_copy_string(ctrl->ev.ringing.calledname, c->remote_id.name.str, sizeof(ctrl->ev.ringing.calledname));
 			libpri_copy_string(ctrl->ev.ringing.callednum, (c->redirecting.to.number.str[0]) ? c->redirecting.to.number.str : c->called_number.str, sizeof(ctrl->ev.ringing.callednum));
-			ctrl->ev.ringing.calledpres = c->called_name.presentation;
+			ctrl->ev.ringing.calledpres = c->remote_id.name.presentation;
 			ctrl->ev.ringing.calledplan = c->called_number.plan;
 		}
 		libpri_copy_string(ctrl->ev.ringing.useruserinfo, c->useruserinfo, sizeof(ctrl->ev.ringing.useruserinfo));
@@ -4147,10 +4144,10 @@
 		ctrl->ev.answer.call = c;
 		ctrl->ev.answer.progress = c->progress;
 		ctrl->ev.answer.progressmask = c->progressmask;
-		libpri_copy_string(ctrl->ev.answer.connectednum, c->connected_line.number.str, sizeof(ctrl->ev.answer.connectednum));
-		libpri_copy_string(ctrl->ev.answer.connectedname, c->connected_line.name.str, sizeof(ctrl->ev.answer.connectedname));
-		ctrl->ev.answer.connectedpres = q931_party_id_presentation(&c->connected_line);
-		ctrl->ev.answer.connectedplan = c->connected_line.number.plan;
+		libpri_copy_string(ctrl->ev.answer.connectednum, c->remote_id.number.str, sizeof(ctrl->ev.answer.connectednum));
+		libpri_copy_string(ctrl->ev.answer.connectedname, c->remote_id.name.str, sizeof(ctrl->ev.answer.connectedname));
+		ctrl->ev.answer.connectedpres = q931_party_id_presentation(&c->remote_id);
+		ctrl->ev.answer.connectedplan = c->remote_id.number.plan;
 		ctrl->ev.answer.source = PRI_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
 		libpri_copy_string(ctrl->ev.answer.useruserinfo, c->useruserinfo, sizeof(ctrl->ev.answer.useruserinfo));
 		c->useruserinfo[0] = '\0';
@@ -4201,10 +4198,10 @@
 						struct pri_subcmd_redirecting *cmdr = &subcmd->redirecting;
 
 						subcmd->cmd = PRI_SUBCMD_REDIRECTING;
-						libpri_copy_string(cmdr->party.from.number, c->connected_line.number.str, sizeof(cmdr->party.from.number));
-						libpri_copy_string(cmdr->party.from.name, c->connected_line.name.str, sizeof(cmdr->party.from.name));
-						cmdr->party.from.number_type = c->connected_line.number.plan;
-						cmdr->party.from.number_presentation = q931_party_id_presentation(&c->connected_line);
+						libpri_copy_string(cmdr->party.from.number, c->remote_id.number.str, sizeof(cmdr->party.from.number));
+						libpri_copy_string(cmdr->party.from.name, c->remote_id.name.str, sizeof(cmdr->party.from.name));
+						cmdr->party.from.number_type = c->remote_id.number.plan;
+						cmdr->party.from.number_presentation = q931_party_id_presentation(&c->remote_id);
 						libpri_copy_string(cmdr->party.to.number, c->ct_complete.number.str, sizeof(cmdr->party.to.number));
 						libpri_copy_string(cmdr->party.to.name, c->ct_complete.name.str, sizeof(cmdr->party.to.name));
 						cmdr->party.to.number_type = c->ct_complete.number.plan;
@@ -4268,10 +4265,10 @@
 				ctrl->ev.facility.call = c;
 
 				/* Need to do this for backward compatibility with struct pri_event_facname */
-				libpri_copy_string(ctrl->ev.facility.callingname, c->caller_id.name.str, sizeof(ctrl->ev.facility.callingname));
-				libpri_copy_string(ctrl->ev.facility.callingnum, c->caller_id.number.str, sizeof(ctrl->ev.facility.callingnum));
-				ctrl->ev.facility.callingpres = q931_party_id_presentation(&c->caller_id);
-				ctrl->ev.facility.callingplan = c->caller_id.number.plan;
+				libpri_copy_string(ctrl->ev.facility.callingname, c->remote_id.name.str, sizeof(ctrl->ev.facility.callingname));
+				libpri_copy_string(ctrl->ev.facility.callingnum, c->remote_id.number.str, sizeof(ctrl->ev.facility.callingnum));
+				ctrl->ev.facility.callingpres = q931_party_id_presentation(&c->remote_id);
+				ctrl->ev.facility.callingplan = c->remote_id.number.plan;
 
 				return Q931_RES_HAVEEVENT;
 			}




More information about the libpri-commits mailing list