[Asterisk-code-review] pjsip options: wrongly applied "UNKNOWN" status (asterisk[master])

Jenkins2 asteriskteam at digium.com
Fri Dec 15 09:49:51 CST 2017


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/7481 )

Change subject: pjsip_options: wrongly applied "UNKNOWN" status
......................................................................

pjsip_options: wrongly applied "UNKNOWN" status

A couple of places were setting the status to "UNKNOWN" when qualifies were
being disabled. Instead this should be set to the "CREATED" status that
represents when a contact is given (uri available), but the qualify frequency
is set to zero so we don't know the status.

This patch updates the relevant places with "CREATED". It also updates the
"CREATED" status description (value shown in CLI/AMI/ARI output) to a value
of "NonQualified"/"NonQual" as this description is hopefully less confusing.

ASTERISK-27467

Change-Id: Id67509d25df92a72eb3683720ad2a95a27b50c89
---
M CHANGES
M UPGRADE.txt
M include/asterisk/res_pjsip.h
M main/stasis_endpoints.c
M res/res_pjsip.c
M res/res_pjsip/pjsip_options.c
M rest-api/api-docs/events.json
7 files changed, 37 insertions(+), 24 deletions(-)

Approvals:
  Joshua Colp: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/CHANGES b/CHANGES
index b2b7409..f367f46 100644
--- a/CHANGES
+++ b/CHANGES
@@ -26,6 +26,17 @@
    headers be retrieved from the REFER message and made accessible to the
    dialplan in the hash TRANSFER_DATA.
 
+AMI
+------------------
+ * The ContactStatus and Status fields for the manager events ContactStatus
+   and ContactStatusDetail are now set to "NonQualified" when a contact exists
+   but has not been qualified.
+
+ARI
+------------------
+ * The ContactInfo event's contact_status field is now set to "NonQualified"
+   when a contact exists but has not been qualified.
+
 ------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 15.1.0 to Asterisk 15.2.0 ------------
 ------------------------------------------------------------------------------
diff --git a/UPGRADE.txt b/UPGRADE.txt
index 39c0f8c..dd37b25 100644
--- a/UPGRADE.txt
+++ b/UPGRADE.txt
@@ -31,6 +31,15 @@
    built.  Users should migrate to app_stack (Gosub).  A warning is logged
    the first time any Macro is used.
 
+AMI:
+ - The ContactStatus and Status fields for the manager events ContactStatus
+   and ContactStatusDetail are now set to "NonQualified" when a contact exists
+   but has not been qualified.
+
+ARI:
+ - The ContactInfo event's contact_status field is now set to "NonQualified"
+   when a contact exists but has not been qualified.
+
 New in 15.0.0:
 
 Build System:
diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h
index e71eb98..6c48d2e 100644
--- a/include/asterisk/res_pjsip.h
+++ b/include/asterisk/res_pjsip.h
@@ -289,9 +289,13 @@
  * \brief Status type for a contact.
  */
 enum ast_sip_contact_status_type {
+	/*! Frequency > 0, but no response from remote uri */
 	UNAVAILABLE,
+	/*! Frequency > 0, and got response from remote uri */
 	AVAILABLE,
+	/*! Default last status, and when a contact status object is not found */
 	UNKNOWN,
+	/*! Frequency == 0, has a contact, but don't know status (non-qualified) */
 	CREATED,
 	REMOVED,
 };
diff --git a/main/stasis_endpoints.c b/main/stasis_endpoints.c
index 161fdfa..5cee22e 100644
--- a/main/stasis_endpoints.c
+++ b/main/stasis_endpoints.c
@@ -82,7 +82,7 @@
 						<enum name="Unknown"/>
 						<enum name="Unreachable"/>
 						<enum name="Reachable"/>
-						<enum name="Created"/>
+						<enum name="Unqualified"/>
 						<enum name="Removed"/>
 						<enum name="Updated"/>
 					</enumlist>
diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index 21e43f0..b50ee5f 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -2282,6 +2282,7 @@
 					<enumlist>
 						<enum name="Reachable"/>
 						<enum name="Unreachable"/>
+						<enum name="NonQualified"/>
 					</enumlist>
 				</parameter>
 				<parameter name="RoundtripUsec">
diff --git a/res/res_pjsip/pjsip_options.c b/res/res_pjsip/pjsip_options.c
index 662166c..63e5ef6 100644
--- a/res/res_pjsip/pjsip_options.c
+++ b/res/res_pjsip/pjsip_options.c
@@ -41,7 +41,7 @@
 	[UNAVAILABLE] = "Unreachable",
 	[AVAILABLE] = "Reachable",
 	[UNKNOWN] = "Unknown",
-	[CREATED] = "Created",
+	[CREATED] = "NonQualified",
 	[REMOVED] = "Removed",
 };
 
@@ -49,7 +49,7 @@
 	[UNAVAILABLE] = "Unavail",
 	[AVAILABLE] = "Avail",
 	[UNKNOWN] = "Unknown",
-	[CREATED] = "Created",
+	[CREATED] = "NonQual",
 	[REMOVED] = "Removed",
 };
 
@@ -205,24 +205,12 @@
 		return;
 	}
 
-	if (is_contact_refresh
-		&& status->status == CREATED) {
-		/*
-		 * The contact status hasn't been updated since creation
-		 * and we don't want to re-send a created status.
-		 */
-		if (contact->qualify_frequency
-			|| status->rtt_start.tv_sec > 0) {
-			/* Ignore, the status will change soon. */
-			return;
-		}
-
-		/*
-		 * Convert to a regular contact status update
-		 * because the status may never change.
-		 */
-		is_contact_refresh = 0;
-		value = UNKNOWN;
+	/*
+	 * If the current status is CREATED, and it's a refresh or the given value is
+	 * also CREATED then there is nothing to update as nothing needs to change.
+	 */
+	if (status->status == CREATED && (is_contact_refresh || status->status == value)) {
+		return;
 	}
 
 	update = ast_sorcery_alloc(ast_sip_get_sorcery(), CONTACT_STATUS,
@@ -595,7 +583,7 @@
 
 		schedule_qualify(contact, contact->qualify_frequency * 1000);
 	} else {
-		update_contact_status(contact, UNKNOWN, 0);
+		update_contact_status(contact, CREATED, 0);
 	}
 }
 
@@ -1127,7 +1115,7 @@
 	if (contact->qualify_frequency) {
 		schedule_qualify(contact, initial_interval);
 	} else {
-		update_contact_status(contact, UNKNOWN, 0);
+		update_contact_status(contact, CREATED, 0);
 	}
 }
 
diff --git a/rest-api/api-docs/events.json b/rest-api/api-docs/events.json
index 9ebbac0..e1b31bb 100644
--- a/rest-api/api-docs/events.json
+++ b/rest-api/api-docs/events.json
@@ -207,7 +207,7 @@
 							"Unreachable",
 							"Reachable",
 							"Unknown",
-							"Created",
+							"NonQualified",
 							"Removed"
 						]
 					}

-- 
To view, visit https://gerrit.asterisk.org/7481
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Id67509d25df92a72eb3683720ad2a95a27b50c89
Gerrit-Change-Number: 7481
Gerrit-PatchSet: 2
Gerrit-Owner: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20171215/7c86f199/attachment.html>


More information about the asterisk-code-review mailing list