[asterisk-commits] mjordan: branch certified-13.1 r430086 - in /certified/branches/13.1: ./ conf...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Dec 24 07:27:17 CST 2014


Author: mjordan
Date: Wed Dec 24 07:27:13 2014
New Revision: 430086

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=430086
Log:
res_pjsip_keepalive: Add runtime configurable keepalive module for connection-oriented transports.

Note that this is backport from trunk of r425825.

This change adds a module which is configurable using the keep_alive_interval setting in the
global section that will send a CRLF keep alive to all active connection-oriented transports at
the provided interval. This is useful because it can help keep connections open through NATs.
This functionality also exists within PJSIP but can not be controlled at runtime and requires
recompiling it.

Review: https://reviewboard.asterisk.org/r/4084/
........

Merged revisions 430084 from http://svn.asterisk.org/svn/asterisk/branches/13

Added:
    certified/branches/13.1/res/res_pjsip_keepalive.c
      - copied unchanged from r430084, branches/13/res/res_pjsip_keepalive.c
Modified:
    certified/branches/13.1/   (props changed)
    certified/branches/13.1/CHANGES
    certified/branches/13.1/configs/samples/pjsip.conf.sample
    certified/branches/13.1/include/asterisk/res_pjsip.h
    certified/branches/13.1/res/res_pjsip.c
    certified/branches/13.1/res/res_pjsip/config_global.c

Propchange: certified/branches/13.1/
------------------------------------------------------------------------------
--- branch-13-merged (original)
+++ branch-13-merged Wed Dec 24 07:27:13 2014
@@ -1,1 +1,1 @@
-/branches/13:429128-429222,429224-429246,429407,429409,429433,429477,429497,429540,429571,429739,429741,429761,429829,430010,430034,430083
+/branches/13:429128-429222,429224-429246,429407,429409,429433,429477,429497,429540,429571,429739,429741,429761,429829,430010,430034,430083-430084

Modified: certified/branches/13.1/CHANGES
URL: http://svnview.digium.com/svn/asterisk/certified/branches/13.1/CHANGES?view=diff&rev=430086&r1=430085&r2=430086
==============================================================================
--- certified/branches/13.1/CHANGES (original)
+++ certified/branches/13.1/CHANGES Wed Dec 24 07:27:13 2014
@@ -15,6 +15,10 @@
 ------------------
  * New 'user_eq_phone' endpoint setting. This adds a 'user=phone' parameter
    to the request URI and From URI if the user is determined to be a phone number.
+
+ * New global setting 'keep_alive_interval'. Setting this to a non-zero value
+   will cause keep alive messages to be sent periodically over connection
+   oriented transports.
 
 ARI
 ------------------

Modified: certified/branches/13.1/configs/samples/pjsip.conf.sample
URL: http://svnview.digium.com/svn/asterisk/certified/branches/13.1/configs/samples/pjsip.conf.sample?view=diff&rev=430086&r1=430085&r2=430086
==============================================================================
--- certified/branches/13.1/configs/samples/pjsip.conf.sample (original)
+++ certified/branches/13.1/configs/samples/pjsip.conf.sample Wed Dec 24 07:27:13 2014
@@ -858,6 +858,9 @@
                                                         ; int")
 ;debug=no ; Enable/Disable SIP debug logging.  Valid options include yes|no
           ; or a host address (default: "no")
+;keep_alive_interval=20 ; The interval (in seconds) at which to send keepalive
+                        ; messages on all active connection-oriented transports
+                        ; (default: "0")
 
 
 ; MODULE PROVIDING BELOW SECTION(S): res_pjsip_acl

Modified: certified/branches/13.1/include/asterisk/res_pjsip.h
URL: http://svnview.digium.com/svn/asterisk/certified/branches/13.1/include/asterisk/res_pjsip.h?view=diff&rev=430086&r1=430085&r2=430086
==============================================================================
--- certified/branches/13.1/include/asterisk/res_pjsip.h (original)
+++ certified/branches/13.1/include/asterisk/res_pjsip.h Wed Dec 24 07:27:13 2014
@@ -1967,4 +1967,11 @@
 		}						\
 	} while(0)
 
+/*!
+ * \brief Retrieve the system keep alive interval setting.
+ *
+ * \retval the keep alive interval.
+ */
+unsigned int ast_sip_get_keep_alive_interval(void);
+
 #endif /* _RES_PJSIP_H */

Modified: certified/branches/13.1/res/res_pjsip.c
URL: http://svnview.digium.com/svn/asterisk/certified/branches/13.1/res/res_pjsip.c?view=diff&rev=430086&r1=430085&r2=430086
==============================================================================
--- certified/branches/13.1/res/res_pjsip.c (original)
+++ certified/branches/13.1/res/res_pjsip.c Wed Dec 24 07:27:13 2014
@@ -1167,6 +1167,9 @@
 				</para></description>
 				<configOption name="max_forwards" default="70">
 					<synopsis>Value used in Max-Forwards header for SIP requests.</synopsis>
+				</configOption>
+				<configOption name="keep_alive_interval" default="0">
+					<synopsis>The interval (in seconds) to send keepalives to active connection-oriented transports.</synopsis>
 				</configOption>
 				<configOption name="type">
 					<synopsis>Must be of type 'global'.</synopsis>

Modified: certified/branches/13.1/res/res_pjsip/config_global.c
URL: http://svnview.digium.com/svn/asterisk/certified/branches/13.1/res/res_pjsip/config_global.c?view=diff&rev=430086&r1=430085&r2=430086
==============================================================================
--- certified/branches/13.1/res/res_pjsip/config_global.c (original)
+++ certified/branches/13.1/res/res_pjsip/config_global.c Wed Dec 24 07:27:13 2014
@@ -42,6 +42,8 @@
 	);
 	/* Value to put in Max-Forwards header */
 	unsigned int max_forwards;
+	/* The interval at which to send keep alive messages to active connection-oriented transports */
+	unsigned int keep_alive_interval;
 };
 
 static void global_destructor(void *obj)
@@ -114,6 +116,21 @@
 	return res;
 }
 
+unsigned int ast_sip_get_keep_alive_interval(void)
+{
+	unsigned int interval;
+	struct global_config *cfg = get_global_cfg();
+
+	if (!cfg) {
+		return 0;
+	}
+
+	interval = cfg->keep_alive_interval;
+	ao2_ref(cfg, -1);
+
+	return interval;
+}
+
 int ast_sip_initialize_sorcery_global(void)
 {
 	struct ast_sorcery *sorcery = ast_sip_get_sorcery();
@@ -135,6 +152,8 @@
 			OPT_STRINGFIELD_T, 0, STRFLDSET(struct global_config, default_outbound_endpoint));
 	ast_sorcery_object_field_register(sorcery, "global", "debug", "no",
 			OPT_STRINGFIELD_T, 0, STRFLDSET(struct global_config, debug));
+	ast_sorcery_object_field_register(sorcery, "global", "keep_alive_interval", "",
+			OPT_UINT_T, 0, FLDSET(struct global_config, keep_alive_interval));
 
 	return 0;
 }




More information about the asterisk-commits mailing list