Ticket #407: keep-alive for UDP transports in PJSUA-LIB

git-svn-id: https://svn.pjsip.org/repos/pjproject/trunk@1536 74dad513-b988-da41-8d7b-12977e46ad98
diff --git a/pjsip/include/pjsua-lib/pjsua.h b/pjsip/include/pjsua-lib/pjsua.h
index 579d722..fb324f4 100644
--- a/pjsip/include/pjsua-lib/pjsua.h
+++ b/pjsip/include/pjsua-lib/pjsua.h
@@ -1768,7 +1768,7 @@
  * Default registration interval.
  */
 #ifndef PJSUA_REG_INTERVAL
-#   define PJSUA_REG_INTERVAL	    55
+#   define PJSUA_REG_INTERVAL	    300
 #endif
 
 
@@ -1897,7 +1897,7 @@
 
     /** 
      * Optional interval for registration, in seconds. If the value is zero, 
-     * default interval will be used (PJSUA_REG_INTERVAL, 55 seconds).
+     * default interval will be used (PJSUA_REG_INTERVAL, 300 seconds).
      */
     unsigned	    reg_timeout;
 
@@ -1947,6 +1947,28 @@
      */
     pj_bool_t auto_update_nat;
 
+    /**
+     * Set the interval for periodic keep-alive transmission for this account.
+     * If this value is zero, keep-alive will be disabled for this account.
+     * The keep-alive transmission will be sent to the registrar's address,
+     * after successful registration.
+     *
+     * Even if this setting is enabled, keep-alive transmission is only done
+     * when STUN is enabled in the global #pjsua_config, and the transport
+     * used for registration is UDP. For TCP and TLS transports, keep-alive
+     * is done by the transport themselves.
+     *
+     * Default: 15 (seconds)
+     */
+    unsigned	     ka_interval;
+
+    /**
+     * Specify the data to be transmitted as keep-alive packets.
+     *
+     * Default: CR-LF
+     */
+    pj_str_t	     ka_data;
+
 } pjsua_acc_config;
 
 
@@ -1966,6 +1988,18 @@
 
 
 /**
+ * Duplicate account config.
+ *
+ * @param pool	    Pool to be used for duplicating the config.
+ * @param dst	    Destination configuration.
+ * @param src	    Source configuration.
+ */
+PJ_DECL(void) pjsua_acc_config_dup(pj_pool_t *pool,
+				   pjsua_acc_config *dst,
+				   const pjsua_acc_config *src);
+
+
+/**
  * Account info. Application can query account info by calling 
  * #pjsua_acc_get_info().
  *
diff --git a/pjsip/include/pjsua-lib/pjsua_internal.h b/pjsip/include/pjsua-lib/pjsua_internal.h
index 004c1ca..87d30b9 100644
--- a/pjsip/include/pjsua-lib/pjsua_internal.h
+++ b/pjsip/include/pjsua-lib/pjsua_internal.h
@@ -86,10 +86,14 @@
     int		     srv_port;	    /**< Port number of reg server.	*/
 
     pjsip_regc	    *regc;	    /**< Client registration session.   */
-    pj_timer_entry   reg_timer;	    /**< Registration timer.		*/
     pj_status_t	     reg_last_err;  /**< Last registration error.	*/
     int		     reg_last_code; /**< Last status last register.	*/
 
+    pj_timer_entry   ka_timer;	    /**< Keep-alive timer for UDP.	*/
+    pjsip_transport *ka_transport;  /**< Transport for keep-alive.	*/
+    pj_sockaddr	     ka_target;	    /**< Destination address for K-A	*/
+    unsigned	     ka_target_len; /**< Length of ka_target.		*/
+
     pjsip_route_hdr  route_set;	    /**< Complete route set inc. outbnd.*/
 
     unsigned	     cred_cnt;	    /**< Number of credentials.		*/