[asterisk-commits] kharwell: branch kharwell/pimp_sip_qualify r391402 - in /team/kharwell/pimp_s...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 11 10:40:17 CDT 2013


Author: kharwell
Date: Tue Jun 11 10:40:15 2013
New Revision: 391402

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=391402
Log:
updated docs and fixed rtt init time

Modified:
    team/kharwell/pimp_sip_qualify/res/res_sip.c
    team/kharwell/pimp_sip_qualify/res/res_sip/location.c
    team/kharwell/pimp_sip_qualify/res/res_sip/sip_options.c

Modified: team/kharwell/pimp_sip_qualify/res/res_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_sip_qualify/res/res_sip.c?view=diff&rev=391402&r1=391401&r2=391402
==============================================================================
--- team/kharwell/pimp_sip_qualify/res/res_sip.c (original)
+++ team/kharwell/pimp_sip_qualify/res/res_sip.c Tue Jun 11 10:40:15 2013
@@ -527,6 +527,26 @@
 					</para></description>
 				</configOption>
 			</configObject>
+			<configObject name="contact_status">
+				<synopsis>Status for a contact</synopsis>
+				<description><para>
+					The contact status keeps track of whether or not a contact is reachable
+					and how long it took to qualify the contact (round trip time).
+				</para></description>
+				<configOption name="status">
+					<synopsis>A contact's status</synopsis>
+					<description><para>
+						Maintains the current status for a contact. Valid values are
+						AVAILABLE or UNAVAILABLE.
+					</para></description>
+				</configOption>
+				<configOption name="rtt">
+					<synopsis>Round trip time</synopsis>
+					<description><para>
+						The time, in microseconds, it took to qualify the contact.
+					</para></description>
+				</configOption>
+			</configObject>
 			<configObject name="aor">
 				<synopsis>The configuration for a location of an endpoint</synopsis>
 				<description><para>
@@ -604,7 +624,7 @@
 					</para></description>
 				</configOption>
 				<configOption name="authenticate_qualify" default="no">
-					<synopsis>Authenticates if a qualify request if needed</synopsis>
+					<synopsis>Authenticates a qualify request if needed</synopsis>
 					<description><para>
 						If true and a qualify request receives a challenge or authenticate response
 						authentication is attempted before declaring the contact available.

Modified: team/kharwell/pimp_sip_qualify/res/res_sip/location.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_sip_qualify/res/res_sip/location.c?view=diff&rev=391402&r1=391401&r2=391402
==============================================================================
--- team/kharwell/pimp_sip_qualify/res/res_sip/location.c (original)
+++ team/kharwell/pimp_sip_qualify/res/res_sip/location.c Tue Jun 11 10:40:15 2013
@@ -297,14 +297,14 @@
 	ast_sorcery_object_field_register(sorcery, "contact", "uri", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_contact, uri));
 	ast_sorcery_object_field_register_custom(sorcery, "contact", "expiration_time", "", expiration_str2struct, expiration_struct2str, 0, 0);
 	ast_sorcery_object_field_register(sorcery, "contact", "qualify_frequency", 0, OPT_UINT_T,
-					  PARSE_IN_RANGE, FLDSET(struct ast_sip_aor, qualify_frequency), 0, 86400);
+					  PARSE_IN_RANGE, FLDSET(struct ast_sip_contact, qualify_frequency), 0, 86400);
 
 	ast_sorcery_object_field_register(sorcery, "aor", "type", "", OPT_NOOP_T, 0, 0);
 	ast_sorcery_object_field_register(sorcery, "aor", "minimum_expiration", "60", OPT_UINT_T, 0, FLDSET(struct ast_sip_aor, minimum_expiration));
 	ast_sorcery_object_field_register(sorcery, "aor", "maximum_expiration", "7200", OPT_UINT_T, 0, FLDSET(struct ast_sip_aor, maximum_expiration));
 	ast_sorcery_object_field_register(sorcery, "aor", "default_expiration", "3600", OPT_UINT_T, 0, FLDSET(struct ast_sip_aor, default_expiration));
 	ast_sorcery_object_field_register(sorcery, "aor", "qualify_frequency", 0, OPT_UINT_T, PARSE_IN_RANGE, FLDSET(struct ast_sip_aor, qualify_frequency), 0, 86400);
-	ast_sorcery_object_field_register(sorcery, "contact", "authenticate_qualify", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_aor, authenticate_qualify));
+	ast_sorcery_object_field_register(sorcery, "aor", "authenticate_qualify", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_aor, authenticate_qualify));
 	ast_sorcery_object_field_register(sorcery, "aor", "max_contacts", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_aor, max_contacts));
 	ast_sorcery_object_field_register(sorcery, "aor", "remove_existing", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_aor, remove_existing));
 	ast_sorcery_object_field_register_custom(sorcery, "aor", "contact", "", permanent_uri_handler, NULL, 0, 0);

Modified: team/kharwell/pimp_sip_qualify/res/res_sip/sip_options.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_sip_qualify/res/res_sip/sip_options.c?view=diff&rev=391402&r1=391401&r2=391402
==============================================================================
--- team/kharwell/pimp_sip_qualify/res/res_sip/sip_options.c (original)
+++ team/kharwell/pimp_sip_qualify/res/res_sip/sip_options.c Tue Jun 11 10:40:15 2013
@@ -111,16 +111,40 @@
 
 	update->status = value;
 
-	/* status is set to unavailable just before sending, so intialize the rrt 
-	   start time to "now", so when we receive a response (status = available)
-	   we can calculate the rtt */
-	if (update->status) {
-		update->rtt = ast_tvdiff_us(ast_tvnow(), status->rtt_start);
-		update->rtt_start = ast_tv(0, 0);
-	} else {
-		update->rtt_start = ast_tvnow();
-		update->rtt = 0;
-	}
+	/* if the contact is available calculate the rtt as
+	   the diff between the last start time and "now" */
+	update->rtt = update->status ?
+		ast_tvdiff_us(ast_tvnow(), status->rtt_start) : 0;
+
+	update->rtt_start = ast_tv(0, 0);
+
+	if (ast_sorcery_update(ast_sip_get_sorcery(), update)) {
+		ast_log(LOG_ERROR, "Unable to update ast_sip_contact_status for contact %s\n",
+			contact->uri);
+	}
+}
+
+/*!
+ * \internal
+ * \brief Initialize the start time on a contact status so the round
+ *        trip time can be calculated upon a valid response.
+ */
+static void init_start_time(const struct ast_sip_contact *contact)
+{
+	RAII_VAR(struct ast_sip_contact_status *, status,
+		 find_or_create_contact_status(contact), ao2_cleanup);
+
+	RAII_VAR(struct ast_sip_contact_status *, update, ast_sorcery_alloc(
+		      ast_sip_get_sorcery(), CONTACT_STATUS,
+		      ast_sorcery_object_get_id(status)), ao2_cleanup);
+
+	if (!update) {
+		ast_log(LOG_ERROR, "Unable to create update ast_sip_contact_status for contact %s\n",
+			contact->uri);
+		return;
+	}
+
+	update->rtt_start = ast_tvnow();
 
 	if (ast_sorcery_update(ast_sip_get_sorcery(), update)) {
 		ast_log(LOG_ERROR, "Unable to update ast_sip_contact_status for contact %s\n",
@@ -246,6 +270,8 @@
 			contact->uri);
 		return -1;
 	}
+
+	init_start_time(contact);
 
 	ao2_ref(contact, +1);
 	if (pjsip_endpt_send_request(ast_sip_get_pjsip_endpoint(),




More information about the asterisk-commits mailing list