[libpri-commits] rmudgett: branch 1.4 r1177 - /branches/1.4/

SVN commits to the libpri project libpri-commits at lists.digium.com
Mon Oct 12 12:17:52 CDT 2009


Author: rmudgett
Date: Mon Oct 12 12:17:48 2009
New Revision: 1177

URL: http://svnview.digium.com/svn/libpri?view=rev&rev=1177
Log:
Miscellaneous changes:

*  Removed unnecessary Q931_IE_CONNECTED_NUM ie from setup_ack_ies[].
*  Added internal state Q931_CALL_STATE_NOT_SET to Q.931 state enum.
*  Made q931_is_ptmp() take a const pointer.
*  pri_facility.c: Some preparations for subaddressing.
*  pri.c: Eliminate use of a magic number.

Modified:
    branches/1.4/pri.c
    branches/1.4/pri_facility.c
    branches/1.4/pri_internal.h
    branches/1.4/pri_q931.h
    branches/1.4/q931.c

Modified: branches/1.4/pri.c
URL: http://svnview.digium.com/svn/libpri/branches/1.4/pri.c?view=diff&rev=1177&r1=1176&r2=1177
==============================================================================
--- branches/1.4/pri.c (original)
+++ branches/1.4/pri.c Mon Oct 12 12:17:48 2009
@@ -223,7 +223,7 @@
 /* Pass in the master for this function */
 void __pri_free_tei(struct pri * p)
 {
-	free (p);
+	free(p);
 }
 
 struct pri *__pri_new_tei(int fd, int node, int switchtype, struct pri *master, pri_io_cb rd, pri_io_cb wr, void *userdata, int tei, int bri)
@@ -841,7 +841,7 @@
 		return -1;
 	if (cause == -1)
 		/* normal clear cause */
-		cause = 16;
+		cause = PRI_CAUSE_NORMAL_CLEARING;
 	return q931_hangup(pri, call, cause);
 }
 

Modified: branches/1.4/pri_facility.c
URL: http://svnview.digium.com/svn/libpri/branches/1.4/pri_facility.c?view=diff&rev=1177&r1=1176&r2=1177
==============================================================================
--- branches/1.4/pri_facility.c (original)
+++ branches/1.4/pri_facility.c Mon Oct 12 12:17:48 2009
@@ -514,6 +514,7 @@
 		sizeof(q931_number->str));
 	q931_number->plan = numbering_plan_for_q931(ctrl, rose_number->plan)
 		| typeofnumber_for_q931(ctrl, rose_number->ton);
+	q931_number->valid = 1;
 }
 
 /*!
@@ -580,28 +581,29 @@
  * \brief Copy the given rose presented screened party address to the q931_party_number
  *
  * \param ctrl D channel controller for diagnostic messages or global options.
- * \param q931_number Q.931 party number structure
+ * \param q931_address Q.931 party id structure to fill the address
  * \param rose_presented ROSE presented screened party address structure
  *
  * \return Nothing
  */
 static void rose_copy_presented_address_screened_to_q931(struct pri *ctrl,
-	struct q931_party_number *q931_number,
+	struct q931_party_id *q931_address,
 	const struct rosePresentedAddressScreened *rose_presented)
 {
-	q931_party_number_init(q931_number);
-	q931_number->valid = 1;
-	q931_number->presentation = presentation_for_q931(ctrl, rose_presented->presentation);
+	q931_party_number_init(&q931_address->number);
+	q931_address->number.valid = 1;
+	q931_address->number.presentation = presentation_for_q931(ctrl,
+		rose_presented->presentation);
 	switch (rose_presented->presentation) {
 	case 0:	/* presentationAllowedAddress */
 	case 3:	/* presentationRestrictedAddress */
-		q931_number->presentation |=
+		q931_address->number.presentation |=
 			(rose_presented->screened.screening_indicator & PRI_PRES_NUMBER_TYPE);
-		rose_copy_number_to_q931(ctrl, q931_number,
+		rose_copy_number_to_q931(ctrl, &q931_address->number,
 			&rose_presented->screened.number);
 		break;
 	default:
-		q931_number->presentation |= PRI_PRES_USER_NUMBER_UNSCREENED;
+		q931_address->number.presentation |= PRI_PRES_USER_NUMBER_UNSCREENED;
 		break;
 	}
 }
@@ -703,20 +705,22 @@
  *
  * \param ctrl D channel controller for diagnostic messages or global options.
  * \param rose_presented ROSE presented screened party address structure
- * \param q931_number Q.931 party number structure
+ * \param q931_address Q.931 party id structure to get the address
  *
  * \return Nothing
  */
 static void q931_copy_presented_address_screened_to_rose(struct pri *ctrl,
 	struct rosePresentedAddressScreened *rose_presented,
-	const struct q931_party_number *q931_number)
-{
-	if (q931_number->valid) {
+	const struct q931_party_id *q931_address)
+{
+	if (q931_address->number.valid) {
 		rose_presented->presentation =
-			presentation_from_q931(ctrl, q931_number->presentation, q931_number->str[0]);
+			presentation_from_q931(ctrl, q931_address->number.presentation,
+				q931_address->number.str[0]);
 		rose_presented->screened.screening_indicator =
-			q931_number->presentation & PRI_PRES_NUMBER_TYPE;
-		q931_copy_number_to_rose(ctrl, &rose_presented->screened.number, q931_number);
+			q931_address->number.presentation & PRI_PRES_NUMBER_TYPE;
+		q931_copy_number_to_rose(ctrl, &rose_presented->screened.number,
+			&q931_address->number);
 		rose_presented->screened.subaddress.length = 0;
 	} else {
 		rose_presented->presentation = 2;/* numberNotAvailableDueToInterworking */
@@ -2868,8 +2872,8 @@
 	case ROSE_QSIG_CallTransferActive:
 		call->incoming_ct_state = INCOMING_CT_STATE_POST_CONNECTED_LINE;
 
-		/* connectedAddress is put in remote_id.number */
-		rose_copy_presented_address_screened_to_q931(ctrl, &call->remote_id.number,
+		/* connectedAddress is put in remote_id */
+		rose_copy_presented_address_screened_to_q931(ctrl, &call->remote_id,
 			&invoke->args.qsig.CallTransferActive.connected);
 
 		/* connectedName is put in remote_id.name */
@@ -2953,7 +2957,6 @@
 			break;
 		case QSIG_NOTIFICATION_WITH_DIVERTED_TO_NR:
 			q931_party_number_init(&call->redirecting.to.number);
-			call->redirecting.to.number.valid = 1;
 			rose_copy_number_to_q931(ctrl, &call->redirecting.to.number,
 				&invoke->args.qsig.DivertingLegInformation1.nominated_number);
 			if (call->redirecting.to.number.str[0]) {

Modified: branches/1.4/pri_internal.h
URL: http://svnview.digium.com/svn/libpri/branches/1.4/pri_internal.h?view=diff&rev=1177&r1=1176&r2=1177
==============================================================================
--- branches/1.4/pri_internal.h (original)
+++ branches/1.4/pri_internal.h Mon Oct 12 12:17:48 2009
@@ -505,9 +505,9 @@
 void q931_party_id_fixup(const struct pri *ctrl, struct q931_party_id *id);
 int q931_party_id_presentation(const struct q931_party_id *id);
 
-const char *q931_call_state_str(int callstate);
-
-int q931_is_ptmp(struct pri *ctrl);
+const char *q931_call_state_str(enum Q931_CALL_STATE callstate);
+
+int q931_is_ptmp(const struct pri *ctrl);
 struct pri_subcommand *q931_alloc_subcommand(struct pri *ctrl);
 
 int q931_notify_redirection(struct pri *ctrl, q931_call *call, int notify, const struct q931_party_number *number);

Modified: branches/1.4/pri_q931.h
URL: http://svnview.digium.com/svn/libpri/branches/1.4/pri_q931.h?view=diff&rev=1177&r1=1176&r2=1177
==============================================================================
--- branches/1.4/pri_q931.h (original)
+++ branches/1.4/pri_q931.h Mon Oct 12 12:17:48 2009
@@ -413,8 +413,15 @@
 	Q931_CALL_STATE_CALL_INDEPENDENT_SERVICE = 31,
 	Q931_CALL_STATE_RESTART_REQUEST = 61,
 	Q931_CALL_STATE_RESTART = 62,
+	/*!
+	 * \details
+	 * Call state has not been set.
+	 * Call state does not exist.
+	 * Call state not initialized.
+	 * Call state internal use only.
+	 */
+	Q931_CALL_STATE_NOT_SET = 0xFF,
 };
-
 
 /* EuroISDN  */
 #define Q931_SENDING_COMPLETE		0xa1

Modified: branches/1.4/q931.c
URL: http://svnview.digium.com/svn/libpri/branches/1.4/q931.c?view=diff&rev=1177&r1=1176&r2=1177
==============================================================================
--- branches/1.4/q931.c (original)
+++ branches/1.4/q931.c Mon Oct 12 12:17:48 2009
@@ -281,7 +281,7 @@
  * \retval TRUE if in PTMP mode.
  * \retval FALSE otherwise.
  */
-int q931_is_ptmp(struct pri *ctrl)
+int q931_is_ptmp(const struct pri *ctrl)
 {
 	/* Check master control structure */
 	for (; ctrl->master; ctrl = ctrl->master) {
@@ -2136,7 +2136,7 @@
  *
  * \return String equivalent of the given Q.931 call state.
  */
-const char *q931_call_state_str(int callstate)
+const char *q931_call_state_str(enum Q931_CALL_STATE callstate)
 {
 	static struct msgtype callstates[] = {
 /* *INDENT-OFF* */
@@ -2160,9 +2160,10 @@
 		{ Q931_CALL_STATE_CALL_INDEPENDENT_SERVICE, "Call Independent Service" },
 		{ Q931_CALL_STATE_RESTART_REQUEST,          "Restart Request" },
 		{ Q931_CALL_STATE_RESTART,                  "Restart" },
+		{ Q931_CALL_STATE_NOT_SET,                  "Not set. Internal use only." },
 /* *INDENT-ON* */
 	};
-	return code2str(callstate, callstates, sizeof(callstates) / sizeof(callstates[0]));
+	return code2str(callstate, callstates, ARRAY_LEN(callstates));
 }
 
 static void dump_call_state(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
@@ -3069,7 +3070,7 @@
 	cur->newcall = 1;
 	cur->ourcallstate = Q931_CALL_STATE_NULL;
 	cur->peercallstate = Q931_CALL_STATE_NULL;
-	cur->sugcallstate = -1;
+	cur->sugcallstate = Q931_CALL_STATE_NOT_SET;
 	cur->ri = -1;
 	cur->transcapability = -1;
 	cur->transmoderate = -1;
@@ -3702,7 +3703,7 @@
 	return send_message(ctrl, c, Q931_ALERTING, alerting_ies);
 }
 
-static int setup_ack_ies[] = { Q931_CHANNEL_IDENT, Q931_IE_FACILITY, Q931_PROGRESS_INDICATOR, Q931_IE_CONNECTED_NUM, -1 };
+static int setup_ack_ies[] = { Q931_CHANNEL_IDENT, Q931_IE_FACILITY, Q931_PROGRESS_INDICATOR, -1 };
  
 int q931_setup_ack(struct pri *ctrl, q931_call *c, int channel, int nonisdn)
 {
@@ -4273,7 +4274,7 @@
 		c->cause = -1;
 		c->causecode = -1;
 		c->causeloc = -1;
-		c->sugcallstate = -1;
+		c->sugcallstate = Q931_CALL_STATE_NOT_SET;
 		c->aoc_units = -1;
 		break;
 	case Q931_RESTART_ACKNOWLEDGE:
@@ -4361,6 +4362,7 @@
 		q931_xmit(ctrl, h, len, 1);
 		return 0;
 	}
+
 	cref = q931_cr(h);
 	c = q931_getcall(ctrl, cref);
 	if (!c) {
@@ -4531,7 +4533,7 @@
  * \brief Fill in the FACILITY event fields.
  *
  * \param ctrl D channel controller.
- * \param call Q.931 call leg
+ * \param call Q.931 call leg.
  *
  * \return Nothing
  */
@@ -4920,6 +4922,7 @@
 			pri_hangup(ctrl, c, c->cause);
 		} else
 			res = 0;
+
 		if (res)
 			return res;
 		else
@@ -5148,7 +5151,7 @@
 	c->cause = -1;
 	c->causecode = -1;
 	c->causeloc = -1;
-	c->sugcallstate = -1;
+	c->sugcallstate = Q931_CALL_STATE_NOT_SET;
 	c->aoc_units = -1;
 
 	UPDATE_OURCALLSTATE(ctrl, c, Q931_CALL_STATE_NULL);




More information about the libpri-commits mailing list