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

SVN commits to the libpri project libpri-commits at lists.digium.com
Tue May 17 15:13:16 CDT 2011


Author: rmudgett
Date: Tue May 17 15:13:10 2011
New Revision: 2266

URL: http://svnview.digium.com/svn/libpri?view=rev&rev=2266
Log:
Option needed for Q931_IE_TIME_DATE to be optional in CONNECT message.

The NEC SV8300 rejects the Q931_IE_TIME_DATE for Q.SIG.

Add option to specify if and how much of the current time is put in
Q931_IE_TIME_DATE.
* Send date/time ie never.
* Send date/time ie date only.
* Send date/time ie date and hour.
* Send date/time ie date, hour, and minute.
* Send date/time ie date, hour, minute, and second.
* Send date/time ie default: Libpri will send date and hhmm only when in
NT PTMP mode to support ISDN phones.

(closes issue #19221)
Reported by: kenner

JIRA SWP-3396

Modified:
    branches/1.4/libpri.h
    branches/1.4/pri.c
    branches/1.4/pri_internal.h
    branches/1.4/q931.c

Modified: branches/1.4/libpri.h
URL: http://svnview.digium.com/svn/libpri/branches/1.4/libpri.h?view=diff&rev=2266&r1=2265&r2=2266
==============================================================================
--- branches/1.4/libpri.h (original)
+++ branches/1.4/libpri.h Tue May 17 15:13:10 2011
@@ -2102,6 +2102,27 @@
 int pri_cc_call(struct pri *ctrl, long cc_id, q931_call *call, struct pri_sr *req);
 void pri_cc_cancel(struct pri *ctrl, long cc_id);
 
+/* Date/time ie send policy option values. */
+#define PRI_DATE_TIME_SEND_DEFAULT		0	/*!< Send date/time ie default. */
+#define PRI_DATE_TIME_SEND_NO			1	/*!< Send date/time ie never. */
+#define PRI_DATE_TIME_SEND_DATE			2	/*!< Send date/time ie date only. */
+#define PRI_DATE_TIME_SEND_DATE_HH		3	/*!< Send date/time ie date and hour. */
+#define PRI_DATE_TIME_SEND_DATE_HHMM	4	/*!< Send date/time ie date, hour, and minute. */
+#define PRI_DATE_TIME_SEND_DATE_HHMMSS	5	/*!< Send date/time ie date, hour, minute, and second. */
+
+/*!
+ * \brief Set the date/time ie send policy option.
+ *
+ * \param ctrl D channel controller.
+ * \param option Policy option to set.
+ *
+ * \note
+ * Only valid in NT mode.
+ *
+ * \return Nothing
+ */
+void pri_date_time_send_option(struct pri *ctrl, int option);
+
 /* Get/Set PRI Timers  */
 #define PRI_GETSET_TIMERS
 int pri_set_timer(struct pri *pri, int timer, int value);

Modified: branches/1.4/pri.c
URL: http://svnview.digium.com/svn/libpri/branches/1.4/pri.c?view=diff&rev=2266&r1=2265&r2=2266
==============================================================================
--- branches/1.4/pri.c (original)
+++ branches/1.4/pri.c Tue May 17 15:13:10 2011
@@ -345,6 +345,27 @@
 }
 
 /*!
+ * \internal
+ * \brief Determine the default date/time send option default.
+ *
+ * \param ctrl D channel controller.
+ *
+ * \return Default date/time send option.
+ */
+static int pri_date_time_send_default(struct pri *ctrl)
+{
+	int date_time_send;
+
+	if (BRI_NT_PTMP(ctrl)) {
+		date_time_send = PRI_DATE_TIME_SEND_DATE_HHMM;
+	} else {
+		date_time_send = PRI_DATE_TIME_SEND_NO;
+	}
+
+	return date_time_send;
+}
+
+/*!
  * \brief Destroy the given link.
  *
  * \param link Q.921 link to destroy.
@@ -565,6 +586,7 @@
 			tei);
 		break;
 	}
+	ctrl->date_time_send = pri_date_time_send_default(ctrl);
 	if (dummy_ctrl) {
 		/* Initialize the dummy call reference call record. */
 		ctrl->link.dummy_call = &dummy_ctrl->dummy_call;
@@ -2174,3 +2196,30 @@
 	}
 	return q931_display_text(ctrl, call, display);
 }
+
+void pri_date_time_send_option(struct pri *ctrl, int option)
+{
+	if (!ctrl) {
+		return;
+	}
+	switch (option) {
+	case PRI_DATE_TIME_SEND_DEFAULT:
+		ctrl->date_time_send = pri_date_time_send_default(ctrl);
+		break;
+	default:
+	case PRI_DATE_TIME_SEND_NO:
+		ctrl->date_time_send = PRI_DATE_TIME_SEND_NO;
+		break;
+	case PRI_DATE_TIME_SEND_DATE:
+	case PRI_DATE_TIME_SEND_DATE_HH:
+	case PRI_DATE_TIME_SEND_DATE_HHMM:
+	case PRI_DATE_TIME_SEND_DATE_HHMMSS:
+		if (NT_MODE(ctrl)) {
+			/* Only networks may send date/time ie. */
+			ctrl->date_time_send = option;
+		} else {
+			ctrl->date_time_send = PRI_DATE_TIME_SEND_NO;
+		}
+		break;
+	}
+}

Modified: branches/1.4/pri_internal.h
URL: http://svnview.digium.com/svn/libpri/branches/1.4/pri_internal.h?view=diff&rev=2266&r1=2265&r2=2266
==============================================================================
--- branches/1.4/pri_internal.h (original)
+++ branches/1.4/pri_internal.h Tue May 17 15:13:10 2011
@@ -189,6 +189,8 @@
 		/*! Receive display text policy option flags. */
 		unsigned long receive;
 	} display_flags;
+	/*! Configured date/time ie send policy option. */
+	int date_time_send;
 };
 
 /*! \brief Maximum name length plus null terminator (From ECMA-164) */

Modified: branches/1.4/q931.c
URL: http://svnview.digium.com/svn/libpri/branches/1.4/q931.c?view=diff&rev=2266&r1=2265&r2=2266
==============================================================================
--- branches/1.4/q931.c (original)
+++ branches/1.4/q931.c Tue May 17 15:13:10 2011
@@ -3082,16 +3082,44 @@
 {
 	time_t now;
 	struct tm timedate;
-
-	/* Send the current time. */
-	time(&now);
-	localtime_r(&now, &timedate);
-	ie->data[0] = timedate.tm_year - 100; /* 1900+ */
-	ie->data[1] = timedate.tm_mon + 1;
-	ie->data[2] = timedate.tm_mday;
-	ie->data[3] = timedate.tm_hour;
-	ie->data[4] = timedate.tm_min;
-	return 7;
+	int ie_len;
+
+	do {
+		if (ctrl->date_time_send < PRI_DATE_TIME_SEND_DATE) {
+			ie_len = 0;
+			break;
+		}
+
+		/* Send the current date/time. */
+		time(&now);
+		localtime_r(&now, &timedate);
+		ie->data[0] = timedate.tm_year - 100; /* 1900+ */
+		ie->data[1] = timedate.tm_mon + 1;
+		ie->data[2] = timedate.tm_mday;
+		ie_len = 2 + 3;
+		if (ctrl->date_time_send < PRI_DATE_TIME_SEND_DATE_HH) {
+			break;
+		}
+
+		/* Add optional hour. */
+		ie->data[3] = timedate.tm_hour;
+		++ie_len;
+		if (ctrl->date_time_send < PRI_DATE_TIME_SEND_DATE_HHMM) {
+			break;
+		}
+
+		/* Add optional minutes. */
+		ie->data[4] = timedate.tm_min;
+		++ie_len;
+		if (ctrl->date_time_send < PRI_DATE_TIME_SEND_DATE_HHMMSS) {
+			break;
+		}
+
+		/* Add optional seconds. */
+		ie->data[5] = timedate.tm_sec;
+		++ie_len;
+	} while (0);
+	return ie_len;
 }
 
 static void dump_keypad_facility(int full_ie, struct pri *ctrl, q931_ie *ie, int len, char prefix)
@@ -5601,16 +5629,6 @@
 	Q931_IE_FACILITY,
 	Q931_PROGRESS_INDICATOR,
 	Q931_DISPLAY,
-	Q931_IE_CONNECTED_NUM,
-	Q931_IE_CONNECTED_SUBADDR,
-	-1
-};
-
-static int connect_net_ies[] = {
-	Q931_CHANNEL_IDENT,
-	Q931_IE_FACILITY,
-	Q931_PROGRESS_INDICATOR,
-	Q931_DISPLAY,
 	Q931_IE_TIME_DATE,
 	Q931_IE_CONNECTED_NUM,
 	Q931_IE_CONNECTED_SUBADDR,
@@ -5675,12 +5693,7 @@
 	} else {
 		q931_display_clear(c);
 	}
-	if (ctrl->localtype == PRI_NETWORK) {
-	    /* networks may send date/time */
-	    return send_message(ctrl, c, Q931_CONNECT, connect_net_ies);
-	} else {
-	    return send_message(ctrl, c, Q931_CONNECT, connect_ies);
-	}
+	return send_message(ctrl, c, Q931_CONNECT, connect_ies);
 }
 
 static int release_ies[] = { Q931_CAUSE, Q931_IE_FACILITY, Q931_IE_USER_USER, -1 };




More information about the libpri-commits mailing list